Skip to content

Commit df69c21

Browse files
jBarzMylesBorins
authored andcommitted
test: check fd 0,1,2 are used, not access mode
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: #10339 Fixes: #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>
1 parent 90d8e11 commit df69c21

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

test/parallel/test-stdio-closed.js

+3-16
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,15 @@
22
const common = require('../common');
33
const assert = require('assert');
44
const spawn = require('child_process').spawn;
5+
const fs = require('fs');
56

67
if (common.isWindows) {
78
common.skip('platform not supported.');
89
return;
910
}
1011

1112
if (process.argv[2] === 'child') {
12-
try {
13-
process.stdout.write('stdout', function() {
14-
try {
15-
process.stderr.write('stderr', function() {
16-
process.exit(42);
17-
});
18-
} catch (e) {
19-
process.exit(84);
20-
}
21-
});
22-
} catch (e) {
23-
assert.strictEqual(e.code, 'EBADF');
24-
assert.strictEqual(e.message, 'EBADF: bad file descriptor, write');
25-
process.exit(126);
26-
}
13+
[0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i)));
2714
return;
2815
}
2916

@@ -32,5 +19,5 @@ const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
3219
const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
3320

3421
proc.on('exit', common.mustCall(function(exitCode) {
35-
assert.strictEqual(exitCode, common.isAix ? 126 : 42);
22+
assert.strictEqual(exitCode, 0);
3623
}));

0 commit comments

Comments
 (0)