How to kill child_process in node.js?

I start out autossh

like

var exec = require('child_process').exec;
var ssh = exec('autossh [...]', function() {});

      

Then when I do ps aux | grep auto

I see that there are 2 processes: /bin/sh -c autossh -M22002 ...

and /usr/lib/autossh/autossh -M22002

. The pid attribute that I can read in node indicates the process /bin/sh

.

Now, when I call .kill

in the handler, the process is /bin/sh

killed and autossh

not. How do you kill them both?

+3
node.js kill


source to share


No one has answered this question yet

Check out similar questions:

2237
How do I pass command line arguments to a Node.js program?
2201
How do you decide when to use Node.js?
1648
How to exit Node.js
1517
How do I debug Node.js applications?
1500
Writing Files in Node.js
1388
What is the purpose of Node.js module.exports and how do you use it?
1264
How to get started with Node.js
1116
Reading environment variables in Node.js
1045
Check synchronously if file / directory exists in Node.js
790
Kill a separate screen session



All Articles
Loading...
X
Show
Funny
Dev
Pics