sse-multiplexd.c: fix leaking pipe FDs

sse-multiplexd leaks pipe FDs to its child processes, so newer children keep
the older ones alive when they should have received a SIGPIPE already

fixes freifunk-gluon/gluon#2468
This commit is contained in:
Matthias Schiffer 2022-06-23 22:38:16 +02:00 committed by Tom Herbers
parent b804281664
commit 12fbaf25ee
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);