Created
May 4, 2010 10:37
-
-
Save bryanwb/389247 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 sys = require('sys'), | |
spawn = require('child_process').spawn, | |
ls = spawn('ls', ['-lh', '/usr']); | |
ls.stdout.addListener('data', function (data) { | |
sys.print('stdout: ' + data); | |
}); | |
ls.stderr.addListener('data', function (data) { | |
sys.print('stderr: ' + data); | |
}); | |
ls.addListener('exit', function (code) { | |
sys.puts('child process exited with code ' + code); | |
}); | |
//Question: Why doesn't the ls child process terminate before event listener for "exit" has been added? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment