Skip to content

Commit

Permalink
start-stop-daemon: remove unnecessary carve-out for pipe FD
Browse files Browse the repository at this point in the history
1364e66 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().
  • Loading branch information
whitslack authored and williamh committed Jan 21, 2023
1 parent 6f44445 commit de295bd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/start-stop-daemon/start-stop-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit de295bd

Please sign in to comment.