mirror of https://github.com/nodejs/node.git
child_process: fix stdio sockets creation
`readable` and `writable` properties can be passed directly to the
`net.Socket` constructor. This change also avoids an unnecessary call
to `read(0)` on the `stdin` socket. This behavior was disclosed when
trying to merge `libuv@1.19.0` and specifically this commit:
fd049399aa
.
PR-URL: https://github.com/nodejs/node/pull/18701
Refs: https://github.com/libuv/libuv/pull/1655
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
pull/18257/merge
parent
f25104e136
commit
b74a6da5d0
|
@ -238,17 +238,7 @@ function flushStdio(subprocess) {
|
|||
|
||||
|
||||
function createSocket(pipe, readable) {
|
||||
var s = new net.Socket({ handle: pipe });
|
||||
|
||||
if (readable) {
|
||||
s.writable = false;
|
||||
s.readable = true;
|
||||
} else {
|
||||
s.writable = true;
|
||||
s.readable = false;
|
||||
}
|
||||
|
||||
return s;
|
||||
return net.Socket({ handle: pipe, readable, writable: !readable });
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ function onexit() {
|
|||
// Usually it is just one event, but it can be more.
|
||||
assert.ok(ioEvents >= 3, `at least 3 stdout io events, got ${ioEvents}`);
|
||||
|
||||
checkInvocations(pipe1, { init: 1, before: 2, after: 2 },
|
||||
checkInvocations(pipe1, { init: 1, before: 1, after: 1 },
|
||||
'pipe wrap when sleep.spawn was called');
|
||||
checkInvocations(pipe2, { init: 1, before: ioEvents, after: ioEvents },
|
||||
'pipe wrap when sleep.spawn was called');
|
||||
|
|
Loading…
Reference in New Issue