summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHumm <hummsmith42@gmail.com>2021-10-13 23:11:40 +0200
committerHumm <hummsmith42@gmail.com>2021-10-13 23:11:40 +0200
commitebfefa84bad5a930df4df85b150c27f1d4fe6de6 (patch)
treeb54edad31ce099d834d25da409592fcd416be530
parentdocument status information and <&- in README (diff)
downloaddwl-ebfefa84bad5a930df4df85b150c27f1d4fe6de6.tar.gz
dwl-ebfefa84bad5a930df4df85b150c27f1d4fe6de6.tar.bz2
dwl-ebfefa84bad5a930df4df85b150c27f1d4fe6de6.tar.xz
dwl-ebfefa84bad5a930df4df85b150c27f1d4fe6de6.tar.zst
dwl-ebfefa84bad5a930df4df85b150c27f1d4fe6de6.zip
-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).
-rw-r--r--dwl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index 6303c25..f84460f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1823,11 +1823,13 @@ run(char *startup_cmd)
EBARF("startup: fork");
if (startup_pid == 0) {
dup2(piperw[0], STDIN_FILENO);
+ close(piperw[0]);
close(piperw[1]);
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
EBARF("startup: execl");
}
dup2(piperw[1], STDOUT_FILENO);
+ close(piperw[1]);
close(piperw[0]);
}
/* If nobody is reading the status output, don't terminate */