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.
process: provide dummy stdio for non-console Windows apps
The only known condition where we could not provide appropriate stdio streams so far were non-console Windows applications. Since this issue has come up a few times in our issue tracker now, switch to providing dummy streams for these cases instead. If there are other valid cases in which `uv_guess_handle` fails, and where there is a more sensible way to provide stdio, we’ll probably still find out because the streams don’t work properly either way. Refs: nodejs/help#1251 PR-URL: nodejs#20640 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
Showing
4 changed files
with
68 additions
and
26 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
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,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const child_process = require('child_process'); | ||
|
||
if (common.isWindows) | ||
common.skip('fs.closeSync(n) does not close stdio on Windows'); | ||
|
||
function runTest(fd, streamName, testOutputStream, expectedName) { | ||
const result = child_process.spawnSync(process.execPath, [ | ||
'--expose-internals', | ||
'-e', ` | ||
require('internal/process/stdio').resetStdioForTesting(); | ||
fs.closeSync(${fd}); | ||
const ctorName = process.${streamName}.constructor.name; | ||
process.${testOutputStream}.write(ctorName); | ||
`]); | ||
assert.strictEqual(result[testOutputStream].toString(), expectedName, | ||
`stdout:\n${result.stdout}\nstderr:\n${result.stderr}\n` + | ||
`while running test with fd = ${fd}`); | ||
if (testOutputStream !== 'stderr') | ||
assert.strictEqual(result.stderr.toString(), ''); | ||
} | ||
|
||
runTest(0, 'stdin', 'stdout', 'Readable'); | ||
runTest(1, 'stdout', 'stderr', 'Writable'); | ||
runTest(2, 'stderr', 'stdout', 'Writable'); |