|
|
|
|
|
by CraigJPerry
1563 days ago
|
|
In this scenario you didn’t write any bytes though. You made a call to write to standard out (your process’s file handle 1) and didn’t succeed, you didn’t handle the possible error condition, you just silently ignored it. I think this is pretty cut and dried - the failure is inside your process’s address space and the programmer error is that you haven’t handled a reported error. >> what happens to the bytes AFTER the pipe? There isn’t a pipe involved here, when your process was created it’s stdout was connected to dev/full then your program began executing |
|
Problem is, the error condition is not even that obvious. I tried it, and printf() will happily return the number of bytes written, even when redirecting stdout to /dev/full.
I am not 100% sure, but I think this has to do with the fact that printf uses buffered io, and writing the bytes to the buffer will work. It's only when the buffer is flushed that this will become a problem, but this would need to be handled in the code to show an error message.