Date: Mon, 10 Jun 2024 07:41:27 -0400
From: Zachary Santer <[email protected]>
Message-ID:
<cabklju+es5qo8i-fa-7nkeqjsaymxlrba3315ry52mczq+b...@mail.gmail.com>
| I assume the coproc fd behavior of
| being closed after most forks is not handled through a system fd flag,
| though if there is a system fd flag that would cause an fd to
| automatically be closed in any forked child process,
The next POSIX will include O_CLOFORK and FD_CLOFORK (or names
similar to those) for open (etc) and fcntl(FDFLAGS)) - that is
analogs of O_CLOEXEC and FD_CLOEXEC but applying to fork() rather
than exec*().
The primary motivation is for handling cases where in a multi-threaded
application, one thread is opening a temporary use (private) fd, just
at the same time another is forking. The nature of fork() in multi-
threaded applications means that without something like this there
are unavoidable races which more or less guarantee fd leakage of
the temporary fd (which other threads don't even know exists) into
the newly forked process.
Whether bash is already making use of this new pair of flags (which
don't exist on all that many systems yet) I have no idea.
kre