-
-
Save Southern/00c61b6484fe50c1fb90 to your computer and use it in GitHub Desktop.
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 _spawn = require('child_process').spawn, | |
children = []; | |
function spawn() { | |
var id = children.push(_spawn.apply(null, arguments)) - 1; | |
children[id].on('exit', function() { | |
delete children[id]; | |
}); | |
// If you want to pipe stuff... | |
children[id].stdout.pipe(process.stdout); | |
children[id].stderr.pipe(process.stderr); | |
} | |
function cleanup() { | |
children.forEach(function(child) { | |
child.kill('SIGINT'); | |
}); | |
} | |
spawn('echo', [ 'Test' ]); | |
cleanup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment