Hacker News new | past | comments | ask | show | jobs | submit login
The perils of relying on output streams in C (2011) [pdf] (gnu.org)
42 points by cafebabe1991 on Jan 25, 2019 | hide | past | favorite | 8 comments



djb's old daemontools suite had an interesting solution to the "how to log failure when you can't write to a log" problem: a persistent child process with some space reserved in its argv, where it can stash some error messages which you can see with "ps" even when disks have failed.

http://cr.yp.to/daemontools/readproctitle.html


I still use this technique.



printf and friends was not supposed to be robust, was supposed to be easy to use. C already provides the means to write robust libraries, if that is necessary.


Can you point me to how to do this?



write() is part of Unix, not C.


The "loosing the errno" issue seems to me easily avoidable: just save the current value if ferror returns an error.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: