From 70bc2e32af8a0215b5e1e4e83fb1c00a457cf663 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 6 Dec 2011 21:53:52 +0100 Subject: [PATCH] test: new test, verify that we don't close and reuse fd 0 --- test/fixtures/destroy-stdin.js | 1 + test/simple/test-child-process-fork3.js | 32 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/fixtures/destroy-stdin.js create mode 100644 test/simple/test-child-process-fork3.js diff --git a/test/fixtures/destroy-stdin.js b/test/fixtures/destroy-stdin.js new file mode 100644 index 0000000000..12b12fb026 --- /dev/null +++ b/test/fixtures/destroy-stdin.js @@ -0,0 +1 @@ +process.stdin.destroy(); diff --git a/test/simple/test-child-process-fork3.js b/test/simple/test-child-process-fork3.js new file mode 100644 index 0000000000..a8a8985f05 --- /dev/null +++ b/test/simple/test-child-process-fork3.js @@ -0,0 +1,32 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); +var fork = require('child_process').fork; + +var filename = common.fixturesDir + '/destroy-stdin.js'; + +// Ensure that we don't accidentally close fd 0 and +// reuse it for something else, it causes all kinds +// of obscure bugs. +process.stdin.destroy(); +fork(filename).stdin.on('end', process.exit);