From fae5c5fa03f35c8195525c6b16f5330342b46a3f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Sep 2016 17:26:21 -0700 Subject: [PATCH 1/6] wip --- test/parallel/test-stdio-closed.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js index 0f94289ee96534..cfbfffe80ead67 100644 --- a/test/parallel/test-stdio-closed.js +++ b/test/parallel/test-stdio-closed.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; if (common.isWindows) { common.skip('platform not supported.'); @@ -18,9 +18,13 @@ if (process.argv[2] === 'child') { } // Run the script in a shell but close stdout and stderr. -var cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`; -var proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' }); +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.equal(exitCode, 42); + assert.strictEqual(exitCode, 42); })); + +proc.on('error', (err) => { + throw err; +}); \ No newline at end of file From 847a642e785504110424d64405a8c4e0aeb872d3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Sep 2016 20:15:28 -0700 Subject: [PATCH 2/6] squash: accept other than EBADF --- src/node.cc | 4 ++-- test/parallel/test-stdio-closed.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/node.cc b/src/node.cc index b6ff402724babb..39912f3f2df5f5 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4114,8 +4114,8 @@ inline void PlatformInit() { continue; // Anything but EBADF means something is seriously wrong. We don't // have to special-case EINTR, fstat() is not interruptible. - if (errno != EBADF) - ABORT(); + // if (errno != EBADF) + // ABORT(); if (fd != open("/dev/null", O_RDWR)) ABORT(); } diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js index cfbfffe80ead67..650ea6ee44c0f8 100644 --- a/test/parallel/test-stdio-closed.js +++ b/test/parallel/test-stdio-closed.js @@ -24,7 +24,3 @@ const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' }); proc.on('exit', common.mustCall(function(exitCode) { assert.strictEqual(exitCode, 42); })); - -proc.on('error', (err) => { - throw err; -}); \ No newline at end of file From 30ce6a4a4711fc8407ee774e33ab731280e15d3f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Sep 2016 21:41:04 -0700 Subject: [PATCH 3/6] squash: this will not fix it but eh... --- src/node.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node.cc b/src/node.cc index 39912f3f2df5f5..0b47bd0541b075 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4114,10 +4114,11 @@ inline void PlatformInit() { continue; // Anything but EBADF means something is seriously wrong. We don't // have to special-case EINTR, fstat() is not interruptible. - // if (errno != EBADF) - // ABORT(); - if (fd != open("/dev/null", O_RDWR)) + if (errno != EBADF) ABORT(); + open("/dev/null", O_RDWR); +// if (fd != open("/dev/null", O_RDWR)) +// ABORT(); } CHECK_EQ(err, 0); From a1156d1296eb883855555a5c396a8f1a872e90bd Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Sep 2016 22:02:06 -0700 Subject: [PATCH 4/6] squash: put it back --- src/node.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/node.cc b/src/node.cc index 0b47bd0541b075..b6ff402724babb 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4116,9 +4116,8 @@ inline void PlatformInit() { // have to special-case EINTR, fstat() is not interruptible. if (errno != EBADF) ABORT(); - open("/dev/null", O_RDWR); -// if (fd != open("/dev/null", O_RDWR)) -// ABORT(); + if (fd != open("/dev/null", O_RDWR)) + ABORT(); } CHECK_EQ(err, 0); From ed1019b8eaf809e33055a06f258d123f5ae18f22 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Sep 2016 22:08:36 -0700 Subject: [PATCH 5/6] squash: confirm stdout is blowing up --- test/parallel/test-stdio-closed.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js index 650ea6ee44c0f8..c90373a79c3291 100644 --- a/test/parallel/test-stdio-closed.js +++ b/test/parallel/test-stdio-closed.js @@ -9,6 +9,14 @@ if (common.isWindows) { } if (process.argv[2] === 'child') { + process.stdout.on('error', (err) => { + process.exit(41); + }); + + process.stderr.on('err', (err) => { + process.exit(40); + }); + process.stdout.write('stdout', function() { process.stderr.write('stderr', function() { process.exit(42); From 6b89af0ea7777c31cbac7b0f133f90ecdf590fbb Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 6 Sep 2016 07:03:01 -0700 Subject: [PATCH 6/6] squash: typo fix --- test/parallel/test-stdio-closed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js index c90373a79c3291..36a78e169466d4 100644 --- a/test/parallel/test-stdio-closed.js +++ b/test/parallel/test-stdio-closed.js @@ -13,7 +13,7 @@ if (process.argv[2] === 'child') { process.exit(41); }); - process.stderr.on('err', (err) => { + process.stderr.on('error', (err) => { process.exit(40); });