libc: Close all pipe file descriptors in popen() after dup2() is called

This commit is contained in:
apio 2024-04-18 21:25:13 +02:00
parent fe302f5967
commit 62cb53069c
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -793,11 +793,13 @@ extern "C"
{ {
close(pfds[0]); close(pfds[0]);
dup2(pfds[1], STDOUT_FILENO); dup2(pfds[1], STDOUT_FILENO);
close(pfds[1]);
} }
else else
{ {
close(pfds[1]); close(pfds[1]);
dup2(pfds[0], STDIN_FILENO); dup2(pfds[0], STDIN_FILENO);
close(pfds[0]);
} }
execl("/bin/sh", "sh", "-c", command, nullptr); execl("/bin/sh", "sh", "-c", command, nullptr);