forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
child_process: check for closed pipes after creating socket
After the socket is created, we trigger an empty read to make sure we catch stdio events like closing the stdin file descriptor. Otherwise those events will go undetected until the next stream write. Fixes: nodejs#25131
- Loading branch information
1 parent
36bb31b
commit e6f5a00
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
// Refs: https://github.com/nodejs/node/issues/25131 | ||
const common = require('../common'); | ||
const cp = require('child_process'); | ||
const fs = require('fs'); | ||
|
||
if (process.argv[2] === 'child') { | ||
fs.closeSync(0); | ||
} else { | ||
const child = cp.spawn(process.execPath, [__filename, 'child'], { | ||
stdio: ['pipe', 'inherit', 'inherit'] | ||
}); | ||
|
||
child.stdin.on('close', common.mustCall(() => { | ||
process.exit(0); | ||
})); | ||
|
||
child.on('close', common.mustNotCall(() => {})); | ||
} |