Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd2b80c

Browse filesBrowse files
cjihrigtargos
authored andcommitted
process: avoid using the same fd for ipc and stdio
There is already a check in place to prevent stdin and the IPC channel from sharing a file descriptor. This commit adds a similar check to stdout and stderr. Refs: libuv/libuv#1851 Refs: libuv/libuv#1897 PR-URL: #21466 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent fefa57a commit cd2b80c
Copy full SHA for cd2b80c

File tree

Expand file treeCollapse file tree

1 file changed

+18
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-5
lines changed
Open diff view settings
Collapse file

‎lib/internal/process/stdio.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/stdio.js
+18-5Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,24 @@ function createWritableStdioStream(fd) {
182182
case 'PIPE':
183183
case 'TCP':
184184
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+
190203
stream._type = 'pipe';
191204
break;
192205

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.