Link to the standard:

http://pubs.opengroup.org/onlinepubs/000095399/functions/clo...

Some discussion that is related to this:

http://lwn.net/Articles/365294/

http://stackoverflow.com/questions/7297001/if-close2-fails-w...

Something which I would consider to be "the answer" from Linus for Linux:

http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000...

http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3171...

http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3202...

(Apparently, the first thing Linux does is deallocate the file descriptor; /then/ it starts flushing pending written data. If this process is interrupted, it will return EINTR, but the file descriptor itself is already deallocated, and may have been reused long before close() returned.)

Honestly, after reviewing all of this material, I think the author of this post might simply not know what "unspecified" means (or, alternatively, is making an abstract problem sound overly concrete and blown somewhat out of proportion).

When a specification says "unspecified", it doesn't mean "unknown at runtime, could be anything nondeterministically". It only means that the standard did not specify the result.

Often, this is because there is either a historical artifact or reasonable practical constraint that was posed by one or more vendors that were implementing the standard that meant different implementations simply /weren't/ going to agree on any one value.

However, for any given implementation, there very likely might be a correct answer. In the case of Linux, you should not retry calls to close(): the primary maintainer has told us that it deterministically guarantees the file descriptor is closed even if the function returns EINTR (critical edit: the wording of this sentence was incorrect in original draft).

That said, there may be another implementation out there, possibly one we may use (but with a standard like this, could easily be one that we have never heard of and that already died a death of obscurity years ago) that has the opposite behavior: where EINTR interrupts something (such as pending writes) before the file descriptor is closed, requiring developers to retry.

It is, however, unfortunate that this happened, and the author is right about issues for developers who attempt to use this API "without assuming more than the standard specified".

That said, there may be other options, such as using SA_RESTART, as argued in this discussion I just found (which also happens to talk about the meaning of "unspecified" ;P):

http://permalink.gmane.org/gmane.os.hurd.devel.readers/265

(edit:) Oh, and people may find it interesting that standards like this are often modified over time, with "interpretations" and outright edits. As an example, here is some vaguely related discussion regarding closing file descriptors during process termination:

http://austingroupbugs.net/view.php?id=498

(edit:) Some more existing discussion:

https://sites.google.com/site/michaelsafyan/software-enginee...

http://lists.freebsd.org/pipermail/freebsd-threads/2010-Augu...

http://unix.derkeiler.com/Newsgroups/comp.unix.programmer/20...

http://www.cpptalk.net/image-vp121851.html

http://programming.itags.org/unix-linux-programming/79468/

Another (very long) Linux-specific thread involving some more responses from Linus:

http://lkml.indiana.edu/hypermail/linux/kernel/0207.2/0391.h...

http://lkml.indiana.edu/hypermail/linux/kernel/0207.2/0409.h...

http://lkml.indiana.edu/hypermail/linux/kernel/0207.2/1173.h...

In this thread we also find someone else claiming the standard is "broken":

http://lkml.indiana.edu/hypermail/linux/kernel/0207.2/0413.h...

With a possibly not useful response, that at least demonstrates that the examples from the specification did not retry:

http://lkml.indiana.edu/hypermail/linux/kernel/0207.2/0395.h...