mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 10:19:03 +03:00
Shell: Fix fd leak with pipes
Fixes the problem reported in #3073. While trying to write a test for this, I thought I'd use Shell -c 'for i in $(seq 100) { echo $i }' | head -n 1 but that makes the cpu spin at 100% and doesn't terminate even with this fix here. But at least piping disasm into head now works.
This commit is contained in:
parent
69fc91d974
commit
37d5e3e0df
Notes:
sideshowbarker
2024-07-19 03:54:24 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/37d5e3e0df6 Pull-request: https://github.com/SerenityOS/serenity/pull/3077 Reviewed-by: https://github.com/alimpfard ✅
@ -535,6 +535,10 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
|
||||
perror("dup2(run)");
|
||||
return nullptr;
|
||||
}
|
||||
// dest_fd is closed via the `fds` collector, but rewiring.other_pipe_end->dest_fd
|
||||
// isn't yet in that collector when the first child spawns.
|
||||
if (rewiring.other_pipe_end && close(rewiring.other_pipe_end->dest_fd) < 0)
|
||||
perror("close other pipe end");
|
||||
}
|
||||
|
||||
fds.collect();
|
||||
|
Loading…
Reference in New Issue
Block a user