Refactor the FD_CLOEXEC/O_NONBLOCK code.