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