Steve Graegert wrote:
did not have time to take a closer look at your code, but I think that fputs(3) itself is not the culprit since it does not necessarily set errno when EOF is encountered
Hmmm, interesting - good point. Does anyone know how to go about examining the error-condition in such a case then? where fputs() returns EOF. I also notice on re-reading the man-page for fprintf that it doesn't return EOF in error-situations, but a negative value.
Instead you're duplicating the FDs before associating it with a stream and the call to fcntl(2) call causes the other (new) FD to be put into non-blocking (O_NONBLOCK) as well since the data structures in the kernel are shared among them.
That's what Anders said too, yet I'm pretty certain (I'll obviously have to check again) I checked the the flags of the second fd to make sure it was blocking. But that leads me to this question - how to I have one socket where I want reads to be nonblocking and writes to block? Or am I asking for something impossible? /Per Jessen, Zürich