The problem with the CLOEXEC patch is that to have O_CLOEXEC defined, at least on a current x86-64 ubuntu 13.10 system, _XOPEN_SOURCE must be defined to 700 or greater to enable XOPEN_2K8, which gates the definition of the O_CLOEXEC in fcntl.h (bits/fcntl-linux.h). So my patch works if either _XOPEN_SOURCE is set to 700 or greater, or if _GNU_SOURCE is set (which is how I usually build things, which is why I missed this at first)
Good catch with the ifdef/if... O_CLOEXEC being defined as '0' would not do the right thing.
I'll keep poking around...
-Kenny