On Thu, Jul 5, 2012 at 4:06 PM, Gijs Kunze <[email protected]> wrote: > To isolate potentially crashy code (code that spawns binaries via the > child_process module) from a long-running server process I've been spawning > a node process which executes the code from the server process which in turn > executes all the potentially crashing processes. This way - I figured - the > server process was isolated both from any crashes of the spawned node > program and of any of it's binaries, also the idea of killing the child > process if it's taking too long appeals to me. However I discovered killing > a child process doesn't automatically kill and process that child process > spawns. > > To solve this issue I read up a bit about how signals work in relation to > processes and child processes I found a solution: > > Start the child process with the option 'detached': true, this causes the > child to become part of a new process group > Instead of killing the child process via childProc.kill(signal) kill it with > process.kill(-childProc.pid, signal) (note the - in front of the pid) this > kills the entire process group > > This seems to work on linux, I'm not sure if it works in other environments > but for our current use case that's not important. But what I'm wary about > is using an undocumented feature (granted, it's documented in the POSIX C > library but not Node which wraps it) so I'd like to know if I can rely on > this feature?
Yes, with the friendly reminder that nothing lasts forever. If there ever turns out to be a good reason to stop supporting that, you'll get at least one major cycle of advance warning (e.g. deprecate in 1.0.0, remove in 1.1.0). -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
