News for hackers. Stuff that matters.
Re:A fork() in the road by tobias3 on Wednesday April 10, 2019 @07:51AM (#19623703)
Use O_CLOEXEC everywhere (even third party libs). It's really annoying, but necessary. Means you need to use accept4(), dup3(), popen with an additional "e" (of course all of that needs to be feature tested, during compilation/runtime).
Re:A fork() in the road by gmueckl on Wednesday April 10, 2019 @01:26PM (#19626873)
The catch is that you may not be able to control 3rd party libraries enough to be be able to do all that. Thus all these annoying hacks. To me, the complexity of using fork() and the race conditions around pid reuse are the worst design problems of POSIX systems.
Re:A fork() in the road by cryptonector on Wednesday April 10, 2019 @12:20PM (#19626176)
Win32 has the opposite semantics, that O_CLOEXEC is the default semantics and the app has to request the opposite if it wants it, and this causes problems too. There should have been two flags and the application should have to specify one on every handle-/fd-creating system call. Hindsight is 20/20.