I found a comment here:
/* even if errno is EINTR we have no way of knowing the number * of bytes actually written so we must abort, on systems with * safe interruption of reads, we wouldn't get EINTR anyway. --cld */
The man page in RedHat Linux 8.0 for write states this:
EINTR The call was interrupted by a signal before any data was writ- ten.
On Solaris:
EINTR A signal was caught during the write operation and no data was transferred.
Are you sure it's right to abort the operation even if errno == EINTR?
Yes both the comments and the man pages are correct. Under POSIX, if a read or write is interrupted they have the option of returning -1 or the number of bytes that have been transferred. If they return -1, we have no way of knowing if it was zero, some or all the bytes that have been transferred. On systems that return the number of bytes written, the fact that the reason a short transfer occurred was an EINTR versus a full pipe versus the OS simply being arbitrary is irrelevant because we resume all short writes where it left off. If -1 is returned we don't ever know where to resume writing and therefore the transaction must be aborted.
For RedHat and solaris, if you get EINTR, then you also will have gotten 0 returned from the write() and so the abort never happens, it is instead treated as a short write.
The good news is that FIPS 151.1 clarifies POSIX by adopting POSIX.1 wholesale
and specifically requiring that read and write return the bytes transferred and not -1 on EINTR. You can still check for EINTR if your program has some behavior if writes are interrupted, but this program doesn't and so we resume whenever possible. (FIPS = Federal Information Processing Standard, US Gov't requirements for computer systems.) As the US gov't is the largest single purchasers of POSIX systems, Solaris, HP/UX, etc. all have the better behavior of not returning -1 on EINTR, but there may be other systems that don't so we have to handle it.
I should point out that this is 10003.1-1998 I'm referencing, later it might have been updated to include the FIPS 151.1 clarification but either way the code is the same.
Great. I'll be moving COPY into Maildir today too :). It'll really just be a move of the whole function with only a few tweaks here and there, so go ahead and work on the 1.0.24 tree and I'll merge the patch.
Okay, I may just wait for you to finish, I've got a big deadline on monday and so I'll most likely be dedicating the rest of today to it.
Heh - I created a bogus local user on my machine with a short simple password, and ran
./configure --prefix=`pwd` --sysconfdir=`pwd`/conf
Symlinked src/auth/ binaries to src/ and src/ to bin/. :)
Unfortunately, I work in an environment where user accounts are configured in a central system and therefore bogus users are hard to come by. That and I try to avoid doing any development or testing of code (especially code with calls to unlink() :-) ) as root.
C=)
--
--------------------------------------------------------------------------
Better the hard truth than the comforting fantasy. -- Carl Sagan
--------------------------------------------------------------------------
Caskey <caskey*technocage.com> /// TechnoCage Inc.
--------------------------------------------------------------------------
A presumption on your part does not constitute an obligation on my part.
