I have a simple node script that uses exec to run node scripts.
After adding process.exit(1) calls to the child, its console.error output sometimes goes missing.
// -------------------------------- missing-stderr-output.js
function has(arg) { return (process.argv.indexOf(arg)>-1) }
if (has('child')) {
// console.log('stdout');
console.error('stderr');
process.exit(1);
} else {
var cmd = has('simple')
? 'cat nothing'
: 'node missing-stderr-output.js child';
require('child_process').exec(cmd
,function(e,so,se){
console.log(e);
console.log(so);
console.log(se);
})
}
Note that calling the child code directly shows the stderr output, while calling the
child via .exec loses the child's stderr output.
$ node --version
v0.6.19
$ node missing-stderr-output.js child
stderr
$ node missing-stderr-output.js
{ [Error: Command failed: ] killed: false, code: 1, signal: null }
Note that calling another failing sub-process does not lose stderr output:
$ node missing-stderr-output.js simple
{ [Error: Command failed: cat: nothing: No such file or directory
] killed: false, code: 1, signal: null }
cat: nothing: No such file or directory
Uncommenting the console.log line sometimes outputs both stdout and stderr, sometimes still none.
All of this is on windows, in an msys shell.
As a workaround, replacing
with
process.on('exit',function(){process.exit(1)});
seems to work.
I have a simple node script that uses exec to run node scripts.
After adding process.exit(1) calls to the child, its console.error output sometimes goes missing.
Note that calling the child code directly shows the stderr output, while calling the
child via .exec loses the child's stderr output.
Note that calling another failing sub-process does not lose stderr output:
Uncommenting the console.log line sometimes outputs both stdout and stderr, sometimes still none.
All of this is on windows, in an msys shell.
As a workaround, replacing
with
seems to work.