Closed
Description
var cp = require('child_process');
var fs = require('fs');
if (process.env.CHILD) {
console.error('ERROR');
return;
}
// open child stdout and stderr on our stderr
var options = {
stdio: [0, 2, 2],
env: { CHILD: true },
};
var c = cp.spawn(process.execPath, [__filename], options);
Result: 'ERROR' is not printed.
Excerpt from strace:
[pid 11780] write(2, "ERROR\n", 6) = -1 EBADF (Bad file descriptor)
[pid 11780] write(2, "ERROR\n", 6) = -1 EBADF (Bad file descriptor)
[pid 11780] epoll_ctl(4, EPOLL_CTL_DEL, 2, {EPOLLWRNORM|EPOLLHUP|EPOLLRDHUP|EPOLLET|0x242e0000, {u32=32767, u64=47321597480042495}}) = -1 ENOENT (No such file or directory)
[pid 11780] write(2, "events.js:141\n throw er; //"..., 244) = -1 EBADF (Bad file descriptor)
[pid 11780] exit_group(1) = ?
[pid 11785] +++ exited with 1 +++
This likely a bug in libuv, but reporting it here because that's where I saw it.
Affects node v0.10 and io.js.
/cc @saghul @bnoordhuis I think we tried to fix a variant of this a year or so ago.