← Back to context

Comment by temac

4 years ago

The Windows default can cause problems because of simple logic bugs.

The Unix default can cause unsolvable problems because of races between threads.

You should use CLOEXEC everywhere. Except you can't because you are using libraries.

True. The main problem with the Unix default is that there wasn't a way to set O_CLOEXEC on all new FDs race-free until recently. That's a real problem. FD leaks to children can be bad, but most of the time they are not the end of the world, and often one can steal a closefrom() implementation from a BSD or Illumos as a workaround when you know exactly what you want to allow the child to inherit.