User: Password:
|
|
Subscribe / Log in / New account

When the programmer is forced to handle return codes

When the programmer is forced to handle return codes

Posted Dec 6, 2009 0:05 UTC (Sun) by nix (subscriber, #2304)
In reply to: When the programmer is forced to handle return codes by cras
Parent article: On the importance of return codes

So I guess you know what happens in Linux when close() fails with EINTR (with NFS)? It won't close the fd and it should be retried?
The EINTR happens if a signal arrives while pending writes are being flushed. At this point, the FD is not yet closed. (But if it were, you could retry it anyway, and you'd get EBADF and would know that it had been closed last time around.)

Since you have to loop for write()/read() anyway, looping for close() as well is hardly a killer. (And, yes, I would rather that -EINTR would die die die as fast as possible, but unfortunately it is not dead so we have to deal with it.)


(Log in to post comments)

When the programmer is forced to handle return codes

Posted Dec 6, 2009 0:29 UTC (Sun) by cras (guest, #7000) [Link]

That also makes me wonder about my fsync/fdatasync calls. I suppose they can also fail with EINTR.
Anyway, as I mentioned above, all signals causing those to my program nowdays should be
external so I don't think I will be doing anything about this problem. (Handling is the same for
EINTR as for EDQUOT/ESPACE.) Interesting to realize it could be a problem, of course.

When the programmer is forced to handle return codes

Posted Dec 6, 2009 11:17 UTC (Sun) by nix (subscriber, #2304) [Link]

POSIX documents that fsync() can return EINTR but does not document it for
fdatasync(). This seems likely to be an oversight to me.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds