Skip to content

Commit 1d90700

Browse files
santigimenorvagg
authored andcommitted
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 `[email protected]` and specifically this commit: libuv/libuv@fd04939. PR-URL: #18701 Refs: libuv/libuv#1655 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 1654b12 commit 1d90700

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

‎lib/internal/child_process.js‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,7 @@ function flushStdio(subprocess){
227227

228228

229229
functioncreateSocket(pipe,readable){
230-
vars=newnet.Socket({handle: pipe});
231-
232-
if(readable){
233-
s.writable=false;
234-
s.readable=true;
235-
}else{
236-
s.writable=true;
237-
s.readable=false;
238-
}
239-
240-
returns;
230+
returnnet.Socket({handle: pipe, readable,writable: !readable});
241231
}
242232

243233

‎test/async-hooks/test-pipewrap.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function onexit(){
7878
// Usually it is just one event, but it can be more.
7979
assert.ok(ioEvents>=3,`at least 3 stdout io events, got ${ioEvents}`);
8080

81-
checkInvocations(pipe1,{init: 1,before: 2,after: 2},
81+
checkInvocations(pipe1,{init: 1,before: 1,after: 1},
8282
'pipe wrap when sleep.spawn was called');
8383
checkInvocations(pipe2,{init: 1,before: ioEvents,after: ioEvents},
8484
'pipe wrap when sleep.spawn was called');

0 commit comments

Comments
(0)