How to kill child_process in node.js?

I start out autossh


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?


source to share

All Articles