Permalink
Please
sign in to comment.
Browse files
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: #20640 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information...
Showing
with
68 additions
and 26 deletions.
- +22 −14 doc/api/errors.md
- +0 −3 lib/internal/errors.js
- +19 −9 lib/internal/process/stdio.js
- +27 −0 test/parallel/test-dummy-stdio.js
| @@ -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'); | |||
0 comments on commit
1805236