Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.
Description
Comming from here:
darkguy2008/parallelshell#22
(btw: Usecase for #1009)
Everytime I need to spawn a process I do it like this
if(process.platform==='win32'){sh='cmd';shFlag='/c';}else{sh='sh';shFlag='-c';}varchild=spawn(sh,[shFlag,cmd],{cwd: process.cwd,env: process.env,stdio: ['pipe',process.stdout,process.stderr]})The problem: child is unkillable on unix.
Example in coffee-script:
spawn=require("child_process").spawnchild=spawn"sh", ["-c", "node -e 'setTimeout(function(){},10000);'"] child.on"close", process.exitchild.kill() child.kill("SIGINT") child.kill("SIGTERM") child.kill("SIGHUP") spawn"sh",["-c","kill -TERM "+child.pid] spawn"sh",["-c","kill -INT "+child.pid] spawn"sh",["-c","kill -HUP "+child.pid](on windows it works fine with sh replaced by cmd)
Even when I exit the process with process.exit(), the child stays alive.
Workaround I found:
spawn=require("child_process").spawnchild=spawn"sh", ["-c", "node -e 'setTimeout(function(){},10000);'"], detached:truechild.on"close", process.exitspawn"sh",["-c","kill -INT -"+child.pid]Killing by pgid works, by pid works not. Sending ^C from console works also, I assume it uses pgid always.
kasselTrankos, catamphetamine, LachlanStarick and Hiweus
Metadata
Metadata
Assignees
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.