Create file descriptors with O_CLOEXEC where possible

Where possible and supported by the operating system, pass creation-time flag arguments that create close-on-exec file descriptors. On platforms (e.g. OS X) that don't support pipe2(2), accept4(2), or SOCK_CLOEXEC, fall back to creating non-close-on-exec descriptors.

Based on patches by Greg Brockman, Patrick Collison