mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 20:46:16 +00:00

Don't do a write on stdout/stderr because that checks for their writability. But fd=1 could legitimately be opened with read-only access by the user. All this test needs to ensure is that they are used at startup. PR-URL: https://github.com/nodejs/node/pull/10339 Fixes: https://github.com/nodejs/node/issues/10234 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
24 lines
644 B
JavaScript
24 lines
644 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const spawn = require('child_process').spawn;
|
|
const fs = require('fs');
|
|
|
|
if (common.isWindows) {
|
|
common.skip('platform not supported.');
|
|
return;
|
|
}
|
|
|
|
if (process.argv[2] === 'child') {
|
|
[0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i)));
|
|
return;
|
|
}
|
|
|
|
// Run the script in a shell but close stdout and stderr.
|
|
const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
|
|
const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
|
|
|
|
proc.on('exit', common.mustCall(function(exitCode) {
|
|
assert.strictEqual(exitCode, 0);
|
|
}));
|