Skip to content

Instantly share code, notes, and snippets.

@tieleman
Created March 11, 2014 10:33
Show Gist options
  • Save tieleman/9483184 to your computer and use it in GitHub Desktop.
Save tieleman/9483184 to your computer and use it in GitHub Desktop.
Spawn example JS
var child_process = require('child_process');
job1 = child_process.spawn('sleep', ['5'])
job2 = child_process.spawn('sleep', ['10'])
job1.on('exit', function(code, signal) {
console.log("Job 1 exited with code " + code + " and signal " + signal);
job2.kill(); // Send SIGTERM to other job
})
job2.on('exit', function(code, signal) {
console.log("Job 2 exited with code " + code + " and signal " + signal);
job1.kill(); // Send SIGTERM to other job
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment