I wrote:
Also on RHEL 6.4 (2.6.32-358.18.1.el6.x86_64) with /dev/shm/nosuch. I'll report it to RedHat and see what they say.
https://bugzilla.redhat.com/show_bug.cgi?id=1008073
Simpler fix, at least on Linux:
#ifdef O_DIRECT if ((rc = fcntl(fd, F_GETFL)) != -1) (void) fcntl(fd, F_SETFL, rc | O_DIRECT); #endif
But that could fail elsewhere, if some OS only accepts O_DIRECT to open() and not to fcntl().
BTW, does the nearby Apple code need to fail if fcntl(newfd, F_NOCACHE, 1) fails? Could ignore errors.