Created
March 11, 2014 10:33
-
-
Save tieleman/9483184 to your computer and use it in GitHub Desktop.
Spawn example JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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