File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -161,11 +161,24 @@ function createWritableStdioStream(fd) {
161
161
case 'PIPE' :
162
162
case 'TCP' :
163
163
var net = require ( 'net' ) ;
164
- stream = new net . Socket ( {
165
- fd : fd ,
166
- readable : false ,
167
- writable : true
168
- } ) ;
164
+
165
+ // If fd is already being used for the IPC channel, libuv will return
166
+ // an error when trying to use it again. In that case, create the socket
167
+ // using the existing handle instead of the fd.
168
+ if ( process . channel && process . channel . fd === fd ) {
169
+ stream = new net . Socket ( {
170
+ handle : process . channel ,
171
+ readable : false ,
172
+ writable : true
173
+ } ) ;
174
+ } else {
175
+ stream = new net . Socket ( {
176
+ fd,
177
+ readable : false ,
178
+ writable : true
179
+ } ) ;
180
+ }
181
+
169
182
stream . _type = 'pipe' ;
170
183
break ;
171
184
You can’t perform that action at this time.
0 commit comments