In the section section 2.9.7 in the section "Interaction of streams with ordinary file operations" of the POSIX specification:
All functions are chmod () , close () , fchmod () , fcntl () , fstat () , ftruncate () , lseek () , open () , read () , readlink () , stat () , symlink () and write () must be atomic with respect to each other in the effects specified in IEEE Std 1003.1-2001 when they work with regular files. If each of the two threads calls one of these functions, each call must either see all the specified effects of the other call, or none of them.
So, for a regular file, if a process thread contains locks on file segments and calls close() in the last file descriptor associated with the file, then close() effects (including removing all outstanding file locks that are stored in the process) are atomic with respect to effects calling fcntl() by another process thread to lock the file segment.
The specification for exit() states:
These functions must interrupt the calling process with the following consequences:
All file descriptors, directory streams [, conversion descriptors, and message catalog descriptors] opened in the calling process must be closed.
...
Presumably, open file descriptors are closed, as if the corresponding calls to close() , but, unfortunately, the specification does not say how open file descriptors are βclosedβ.
The 2004 specification seems even more vague when it comes to the steps of abnormally completing the process. The only thing I could find was the documentation for abort() . At least in the 2008 specification, the _Exit() page has a section called Consequences of terminating the process . However, the wording is still:
- All file descriptors, directory streams, conversion descriptors, and message catalog descriptors opened in the calling process must be closed.
UPDATE: I just opened question 0000498 in the Austin group defect report .