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:
parent
b804281664
commit
04d2b6ffbb
|
@ -97,7 +97,7 @@ struct provider {
|
||||||
|
|
||||||
static int run_command(const char *command) {
|
static int run_command(const char *command) {
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
if (pipe(pipefd) < 0) {
|
if (pipe2(pipefd, O_CLOEXEC) < 0) {
|
||||||
syslog(LOG_ERR, "pipe: %s", strerror(errno));
|
syslog(LOG_ERR, "pipe: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -115,12 +115,8 @@ static int run_command(const char *command) {
|
||||||
return pipefd[0];
|
return pipefd[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
close(pipefd[0]);
|
|
||||||
dup2(pipefd[1], STDOUT_FILENO);
|
dup2(pipefd[1], STDOUT_FILENO);
|
||||||
|
|
||||||
if (pipefd[1] != STDOUT_FILENO)
|
|
||||||
close(pipefd[1]);
|
|
||||||
|
|
||||||
struct sigaction action = {};
|
struct sigaction action = {};
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue