-s: close unused fds
dup2 doesn’t close fds, it only duplicates them. The old ones weren’t closed, causing problems (like dwl blocking due to the child process never reading from the reading end, even if stdin has been closed).
This commit is contained in:
parent
2d9740c2fc
commit
ebfefa84ba
2
dwl.c
2
dwl.c
|
@ -1823,11 +1823,13 @@ run(char *startup_cmd)
|
||||||
EBARF("startup: fork");
|
EBARF("startup: fork");
|
||||||
if (startup_pid == 0) {
|
if (startup_pid == 0) {
|
||||||
dup2(piperw[0], STDIN_FILENO);
|
dup2(piperw[0], STDIN_FILENO);
|
||||||
|
close(piperw[0]);
|
||||||
close(piperw[1]);
|
close(piperw[1]);
|
||||||
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
|
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
|
||||||
EBARF("startup: execl");
|
EBARF("startup: execl");
|
||||||
}
|
}
|
||||||
dup2(piperw[1], STDOUT_FILENO);
|
dup2(piperw[1], STDOUT_FILENO);
|
||||||
|
close(piperw[1]);
|
||||||
close(piperw[0]);
|
close(piperw[0]);
|
||||||
}
|
}
|
||||||
/* If nobody is reading the status output, don't terminate */
|
/* If nobody is reading the status output, don't terminate */
|
||||||
|
|
Loading…
Reference in a new issue