Re:How Not to Write a Signal Handler
by userbinator on Friday November 28, 2014 @12:40AM
(#8669814)
I've always found it interesting that the list of safe functions includes read(), write(), and most of the filesystem operations; so while printf is not safe, you could use write() if you really wanted to output.
[ Parent
| on HN ]
write() is an OS system call, while printf() is a C function call.
C libraries can (and do) choose to buffer printf, while read/write are usually unbuffered.
Of course, both are mechanisms are modifying some global state (your terminal's state), and cannot be relied to be free of race-conditions.