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 4856420

Browse filesBrowse files
DaveMyles Borins
authored andcommitted
child_process: flush consuming streams
When a client calls read() with a nonzero argument on a Socket, that Socket sets this._consuming to true. It never sets this._consuming back to false. ChildProcess.flushStdio() currently doesn't flush any streams where _consuming is truthy. But, that means that it never flushes any stream that has ever been read from. This prevents a child process from ever closing if one of its streams has been read from, causing issue #4049. This commit allows consuming streams to be flushed, and the child process to emit a close event. Fixes: #4049 PR-URL: #4071 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent f441410 commit 4856420
Copy full SHA for 4856420

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎lib/internal/child_process.js‎

Copy file name to clipboardExpand all lines: lib/internal/child_process.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ util.inherits(ChildProcess, EventEmitter);
217217
function flushStdio(subprocess) {
218218
if (subprocess.stdio == null) return;
219219
subprocess.stdio.forEach(function(stream, fd, stdio) {
220-
if (!stream || !stream.readable || stream._consuming)
220+
if (!stream || !stream.readable)
221221
return;
222222
stream.resume();
223223
});
Collapse file
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
const cp = require('child_process');
3+
const common = require('../common');
4+
const assert = require('assert');
5+
6+
const p = cp.spawn('echo');
7+
8+
p.on('close', common.mustCall(function(code, signal) {
9+
assert.strictEqual(code, 0);
10+
assert.strictEqual(signal, null);
11+
}));
12+
13+
p.stdout.read();
14+
15+
setTimeout(function() {
16+
p.kill();
17+
}, 100);

0 commit comments

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