2022年11月28日(月) 19:06 Alexey via Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org>: > But we use the fact tat bash doesn't close FD for example to preliminary > open log file for utility that we will `exec' later. > Unfortunately bash doesn't provide any fcntl() mechanism to control FD > flags. > It'll be great to have ability to manage CLOEXEC or any other FD flags > from the script.
There is a loadable builtin `fdflags' to do that. If the loadable builtin is installed (e.g. at /usr/lib/bash/fdflags), we can do something like enable -f /usr/lib/bash/fdflags fdflags fdflags -s +cloexec <fd> -- Koichi