File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -183,11 +183,24 @@ function createWritableStdioStream(fd) {
183
183
case 'PIPE' :
184
184
case 'TCP' :
185
185
var net = require ( 'net' ) ;
186
- stream = new net . Socket ( {
187
- fd : fd ,
188
- readable : false ,
189
- writable : true
190
- } ) ;
186
+
187
+ // If fd is already being used for the IPC channel, libuv will return
188
+ // an error when trying to use it again. In that case, create the socket
189
+ // using the existing handle instead of the fd.
190
+ if ( process . channel && process . channel . fd === fd ) {
191
+ stream = new net . Socket ( {
192
+ handle : process . channel ,
193
+ readable : false ,
194
+ writable : true
195
+ } ) ;
196
+ } else {
197
+ stream = new net . Socket ( {
198
+ fd,
199
+ readable : false ,
200
+ writable : true
201
+ } ) ;
202
+ }
203
+
191
204
stream . _type = 'pipe' ;
192
205
break ;
193
206
You can’t perform that action at this time.
0 commit comments