#!/usr/bin/env node "use strict"; var child_process = require('child_process'); var x = child_process.spawn('sleep', [10]); x.on('exit', function () { throw (new Error("failure")); });
EDIT:
You can listen to the main process by adding a listener to the main process as process.on('exit', function () { x.kill() })
But an error similar to this problem is a problem, it is better to close process.exit()
#!/usr/bin/env node "use strict"; var child_process = require('child_process'); var x = child_process.spawn('sleep', [100]); process.on('exit', function () { x.kill(); }); process.exit(1);
pfried
source share