-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zombie subprocesses #7087
Comments
Example from the gist const command = ['deno', 'run', './script.ts'];
const p1 = Deno.run({ cmd: command })
const p2 = Deno.run({ cmd: command })
const p3 = Deno.run({ cmd: command })
const p4 = Deno.run({ cmd: command })
p1.kill(Deno.Signal.SIGKILL)
p2.kill(Deno.Signal.SIGKILL)
p3.kill(Deno.Signal.SIGKILL)
p4.kill(Deno.Signal.SIGKILL)
setInterval(() => {
// just to keep it running so you can `ps aux | grep deno` to check the zombie processes
}, 1000); |
For background: UNIX expects you to reap zombies with This would normally be an easy fix - set the
A crude hack that papers over the issue: diff --git a/cli/ops/process.rs b/cli/ops/process.rs
index 60a6d5095..b259d9531 100644
--- a/cli/ops/process.rs
+++ b/cli/ops/process.rs
@@ -114,6 +114,13 @@ fn op_run(
// Spawn the command.
let mut child = c.spawn()?;
+
+ #[cfg(unix)]
+ unsafe { libc::signal(libc::SIGCHLD, libc::SIG_IGN); } // Reset signal handler.
+
let pid = child.id();
let stdin_rid = match child.stdin.take() { It's not a good fix however because of the race window between the spawn and signal calls. So far I haven't been able to come up with a better idea than poll child objects in the resource table at a fixed interval. |
I can reproduce this in latest canary. Linux reports all the child processes as zombies |
This is definitely still an issue in latest deno release 1.7.0 and it's a big problem for apps that constantly spawn a lot of child processes. We did end up with non-responsive servers after a huge amount of zombie processes were leaked. Is there any workaround we can do temporarily for now at the application layer before it's fixed in deno runtime, other than letting the deno parent process dies when any child process is killed (which is of course not ideal for long running servers)? |
This issue still happens on v1.7.1 |
This still seems to be an issue on |
Happens when i run firefox as a subprocess on windows |
Any hope on getting this addressed? |
As an alternative, this issue does not appear to happen when using the |
We should migrate to |
I'll close this issue because Upgrade to |
Currently, when creating a subprocess using
Deno.run
, the process stays in "zombie mode" even after it is killed.I've created a gist that reproduces this bug, and talked with @lucacasonato that confirmed it.
https://gist.github.com/asantos00/bdd4357cb91f18b368085eb44105ea97
The text was updated successfully, but these errors were encountered: