There were a few issues. One was the ifdef logic down below. The thing that you want to verify is that all the platforms you care about will return EINVAL when they don't support O_CLOEXEC. If, for example, the kernel doesn't error out on things it doesn't recognize (which does happen in some interfaces), then uv will mistakenly thing it has opened the fd O_CLOEXEC when it hasn't.