Skip to content

Instantly share code, notes, and snippets.

@bahamas10
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save bahamas10/56d99b31ccfa9105dc73 to your computer and use it in GitHub Desktop.

Select an option

Save bahamas10/56d99b31ccfa9105dc73 to your computer and use it in GitHub Desktop.
node 10 child_process readable

readable event called, but calling .read() on the stream results in an empty string.

var cp = require('child_process');
var child = cp.spawn('sysevent');
child.stderr.setEncoding('utf8');
child.stderr.on('readable', function () {
console.log('stderr readable');
var stderr = '';
var chunk;
while ((chunk = child.stderr.read()) !== null)
stderr += chunk;
console.dir(stderr);
console.log('---');
});
child.on('close', function () {});
root - build sunos ~/temp # node child_process_test.js
stderr readable
''
---
stderr readable
'sysevent: sysevent_bind_handle: Bad address\n'
---
stderr readable
''
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment