this won't work reliable (but it should according to the docs):
var empty = new Buffer(0)
process.stdout.write(empty, function() {
process.stderr.write(empty, function() {
process.exit(code);
});
});
Not all data is flushed when node.js ends and thus another process using its output will not get all written data.
It also doesn't help to use something like
stream.pipe(process.stdout);
stream.push(null);
That .end() throws and an finish is never emitted makes using process.stdout/.stderr something like lottery.
Also trying to workaround via
fs.createWritableStream(null, {fd:1});
leads to another bunch of problems like EAGAIN errors.
I would suggest to implement .end() and finish events so that both process.stdout and .stderr behave like any other stream.
Please see https://github.com/nodejs/node/pull/3170 -- the docs are incorrect but the situation is complex.
I recommend you avoid using process.exit() whenever possible.
Please also see https://github.com/nodejs/node/issues/2972#issuecomment-146078649
(Oh dear, this again.)
Yes, this again. And shame on me that I thought node.js could be used to write a unix like tool without looking on the CLOSED issues. The "issue" thing here works as reliable as process.stdout/.stderr ...
See https://github.com/nodejs/node/issues/6456 for the latest.
Most helpful comment
Yes, this again. And shame on me that I thought node.js could be used to write a unix like tool without looking on the CLOSED issues. The "issue" thing here works as reliable as process.stdout/.stderr ...