Guest User

Untitled

a guest
May 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. var sys = require('sys'),
  2. spawn = require('child_process').spawn,
  3. ls = spawn('ls', ['-lh', '/usr']);
  4.  
  5. ls.stdout.addListener('data', function (data) {
  6. sys.print('stdout: ' + data);
  7. });
  8.  
  9. ls.stderr.addListener('data', function (data) {
  10. sys.print('stderr: ' + data);
  11. });
  12.  
  13. ls.addListener('exit', function (code) {
  14. sys.puts('child process exited with code ' + code);
  15. });
  16.  
  17. //Question: Why doesn't the ls child process terminate before event listener for "exit" has been added?
Add Comment
Please, Sign In to add comment