close(2) vs. full filesystems
Contrary to my previous (untested!) expectations, the close(2) system call does not issue an error when closing a file on a full filesystem. Running writetest.c on Mac OS X results in fflush(2) throwing the error, and no error from the close statement.
$ writetest /Volumes/test/file error: problem flushing: file=/Volumes/test/file, errno=No space left on device $ df `pwd` Filesystem 512-blocks Used Avail Capacity Mounted on /dev/disk2s2 1032 1032 0 100% /Volumes/test
Programs, if paranoid, should check each flush or print statement (depending on the language), or checksum the data in memory, then verify what actually ends up in a temporary file, before an atomic rename(2) moves the data into place. System monitoring should also alert on high disk space use, as odds are not all programs behave properly when the disk is full. Or perhaps legal requirements frown on missing logs resulting from negligent disk space management.