From de295bd0c63f15e3d4e797e053826dbacbce556e Mon Sep 17 00:00:00 2001 From: Matt Whitlock Date: Thu, 8 Dec 2022 19:04:19 -0500 Subject: [PATCH] start-stop-daemon: remove unnecessary carve-out for pipe FD 1364e6631c7f266484981d88be43f9b039f76b6a exempted the write end of the synchronization pipe from the close() loop in the child process, but this is unnecessary, as the pipe is opened with O_CLOEXEC, and the child process calls execvp() soon after the close() loop, with the intervening code not needing the pipe. Indeed, the pipe only needs to remain open in the child process until after the call to setsid(), which occurs well before the close() loop. So, eliminate the needless carve-out from the close() loop, in preparation for introducing closefrom(). --- src/start-stop-daemon/start-stop-daemon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/start-stop-daemon/start-stop-daemon.c b/src/start-stop-daemon/start-stop-daemon.c index d3f6fd4d..b3a8edca 100644 --- a/src/start-stop-daemon/start-stop-daemon.c +++ b/src/start-stop-daemon/start-stop-daemon.c @@ -1105,8 +1105,7 @@ int main(int argc, char **argv) dup2(stderr_fd, STDERR_FILENO); for (i = getdtablesize() - 1; i >= 3; --i) - if (i != pipefd[1]) - close(i); + close(i); if (scheduler != NULL) { int scheduler_index;