openrc/src/start-stop-daemon
Matt Whitlock 9dfd2b2737 start-stop-daemon, supervise-daemon: use closefrom()/close_range()
On systems with a very large RLIMIT_NOFILE, calling close() in a loop
from 3 to getdtablesize() effects an enormous number of system calls.
There are better alternatives. Both BSD and Linux have the closefrom()
system call that closes all file descriptors with indices not less than
a specified minimum. Have start-stop-daemon call closefrom() on systems
where it's implemented, falling back to the old loop elsewhere.

Likewise, calling fcntl(i, F_SETFD, FD_CLOEXEC) in a loop from 3 to
getdtablesize() raises a similar performance concern. Linux 5.11 and
onward has a close_range() system call with a CLOSE_RANGE_CLOEXEC flag
that sets the FD_CLOEXEC flag on all file descriptors in a specified
range. Have supervise-daemon utilize this feature on systems where it's
implemented, falling back to the old loop elsewhere.
2023-01-20 21:44:37 -06:00
..
meson.build start-stop-daemon: remove rc-prefix from file names 2022-04-07 11:18:56 -05:00
pipes.c start-stop-daemon: remove rc-prefix from file names 2022-04-07 11:18:56 -05:00
pipes.h start-stop-daemon: remove rc-prefix from file names 2022-04-07 11:18:56 -05:00
start-stop-daemon.c start-stop-daemon, supervise-daemon: use closefrom()/close_range() 2023-01-20 21:44:37 -06:00
start-stop-daemon.pam migrate fully to meson build system 2022-04-06 10:51:55 -05:00