Skip to content

Commit

Permalink
sse-multiplex: fix pipe FD leaks
Browse files Browse the repository at this point in the history
sse-multiplexd leaked pipe FDs to its child processes, so newer children
kept the older ones alive when they should have received a SIGPIPE already.

Closes freifunk-gluon/gluon#2468
  • Loading branch information
neocturne committed Jul 2, 2022
1 parent b804281 commit a2ba87e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions net/sse-multiplex/src/sse-multiplexd.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct provider {

static int run_command(const char *command) {
int pipefd[2];
if (pipe(pipefd) < 0) {
if (pipe2(pipefd, O_CLOEXEC) < 0) {
syslog(LOG_ERR, "pipe: %s", strerror(errno));
return -1;
}
Expand All @@ -115,12 +115,8 @@ static int run_command(const char *command) {
return pipefd[0];
}
else {
close(pipefd[0]);
dup2(pipefd[1], STDOUT_FILENO);

if (pipefd[1] != STDOUT_FILENO)
close(pipefd[1]);

struct sigaction action = {};
sigemptyset(&action.sa_mask);

Expand Down

0 comments on commit a2ba87e

Please sign in to comment.