sse-multiplex: fix pipe FD leaks

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
This commit is contained in:
Matthias Schiffer 2022-06-23 22:38:16 +02:00 committed by Andreas Ziegler
parent b804281664
commit 04d2b6ffbb
1 changed files with 1 additions and 5 deletions

View File

@ -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;
}
@ -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);