Roland McGrath wrote:
But...posix_spawn doesn't give you any way to delete *all* file descriptors
and if you try to collect them before spawning, there is a race in a
multithreaded program.

This is something you should never want to do.  There is notoriously no
good way to do it on some systems, where getdtablesize() can return
RLIM_INFINITY and is not proper to use in a loop.

Use FD_CLOEXEC when you open the descriptor in the first place.

We also need to chdir() before calling exec. And while some descriptors
already have FD_CLOEXEC set, it's not easy to guarantee this for all of them.

- Michael.

Reply via email to