From a9df4f29a20b3940f93fa8d0db90246b2d46ffa6 Mon Sep 17 00:00:00 2001 From: John Barboza Date: Fri, 16 Dec 2016 10:46:20 -0500 Subject: [PATCH] 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. What this test needs to only ensure is that they are used at startup. This fixes https://github.com/nodejs/node/issues/10234 --- test/parallel/test-stdio-closed.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js index a85467f76a6d0f..98e4f980d50dd6 100644 --- a/test/parallel/test-stdio-closed.js +++ b/test/parallel/test-stdio-closed.js @@ -2,6 +2,7 @@ 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.'); @@ -9,21 +10,7 @@ if (common.isWindows) { } if (process.argv[2] === 'child') { - try { - process.stdout.write('stdout', function() { - try { - process.stderr.write('stderr', function() { - process.exit(42); - }); - } catch (e) { - process.exit(84); - } - }); - } catch (e) { - assert.strictEqual(e.code, 'EBADF'); - assert.strictEqual(e.message, 'EBADF: bad file descriptor, write'); - process.exit(126); - } + [0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i))); return; } @@ -32,5 +19,5 @@ 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, common.isAix ? 126 : 42); + assert.strictEqual(exitCode, 0); }));