-
Notifications
You must be signed in to change notification settings - Fork 7.3k
cluster/child_process exit event does not pass signal if child is killed #5832
Comments
That's because the SIGTERM is caught and translated into a graceful exit by node.js:
If you send SIGKILL (which cannot be caught), your test works as you'd expect it to. |
@bnoordhuis And what if the client code wants to do some graceful shutdown by SIGTERM in the forked child when it is still alive? Does node provide any hooks there? |
@behrad process.on('SIGTERM', ...) |
Thank you @bnoordhuis , but my scenario is populating SIGTERM from a master process to child workers. I am using cluster module and I did |
@bnoordhuis's suggestion won't work, because https://gist.github.com/7645421 Don't use Or use strong-cluster-control! |
Just want to make sure this is understood, you need to explicitly shutdown your process when you catch process.on('SIGTERM', function() {
// do stuff
process.exit();
}); |
@trevnorris, yes, that is true... if you catch a signal you no longer get the default signal behaviour (termination in this case). But note original OP is talking about "not getting" signal in worker... which is probably because worker.kill() does a /to @piscisaureus, this and #6042 are the issues we were talking about yesterday, where the cluster |
It appears to instead pass the raw status from wait(2) as code, and null for signal (143 == 0b10001111, the low 0b1111==15==SIGTERM).
node --version
v0.10.9-pre (head of v0.10 branch).
3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Output:
From
The text was updated successfully, but these errors were encountered: