From e447562aaadc96f8f95d6659e4776ce5c1a6c9d6 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 30 Aug 2023 13:20:16 +0200 Subject: 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. --- src/start-stop-daemon/start-stop-daemon.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src') 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; -- cgit v1.2.3