diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2023-08-30 13:20:16 +0200 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2023-09-12 22:53:12 -0500 |
commit | e447562aaadc96f8f95d6659e4776ce5c1a6c9d6 (patch) | |
tree | 442e95dd3c1b7283f9e96f2716625d0122542d47 | |
parent | c199c5cf6e39d6e21b92bddba7beeebcc3afca79 (diff) |
start-stop-daemon: set fds to CLOEXEC instead of closing
Set file descriptors to CLOEXEC instead of closing them before exec,
similar to what we do in supervise-daemon.
Use the share cloexec_fds_from() helper for this.
closefrom() is no longer used so remove the test.
-rw-r--r-- | meson.build | 3 | ||||
-rw-r--r-- | src/start-stop-daemon/start-stop-daemon.c | 7 |
2 files changed, 1 insertions, 9 deletions
diff --git a/meson.build b/meson.build index 4ef3f38e..e77cae09 100644 --- a/meson.build +++ b/meson.build @@ -195,9 +195,6 @@ if cc.compiles(malloc_attribute_test, name : 'malloc attribute with arguments') add_project_arguments('-DHAVE_MALLOC_EXTENDED_ATTRIBUTE', language: 'c') endif -if cc.has_function('closefrom', prefix: '#define _GNU_SOURCE\n#include <unistd.h>') - add_project_arguments('-DHAVE_CLOSEFROM', language: 'c') -endif if cc.has_function('close_range', prefix: '#define _GNU_SOURCE\n#include <unistd.h>') add_project_arguments('-DHAVE_CLOSE_RANGE', language: 'c') endif diff --git a/src/start-stop-daemon/start-stop-daemon.c b/src/start-stop-daemon/start-stop-daemon.c index ef6f454e..3e4a19a1 100644 --- a/src/start-stop-daemon/start-stop-daemon.c +++ b/src/start-stop-daemon/start-stop-daemon.c @@ -1098,12 +1098,7 @@ int main(int argc, char **argv) || rc_yesno(getenv("EINFO_QUIET"))) dup2(stderr_fd, STDERR_FILENO); -#ifdef HAVE_CLOSEFROM - closefrom(3); -#else - for (i = getdtablesize() - 1; i >= 3; --i) - close(i); -#endif + cloexec_fds_from(3); if (scheduler != NULL) { int scheduler_index; |