From 77d1427dccdfa249f3b720d9a9f00fac81c2d0d4 Mon Sep 17 00:00:00 2001 From: Alex Gresnel <31708810+agresnel@users.noreply.github.com> Date: Sat, 9 Sep 2017 11:44:55 -0700 Subject: [PATCH 1/4] Update child_process.js --- lib/child_process.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/child_process.js b/lib/child_process.js index 80914b165fc672..b3df6f141a6d2e 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -93,7 +93,12 @@ exports.fork = function(modulePath /*, args, options*/) { } options.execPath = options.execPath || process.execPath; - + + // Make sure we don't try to shell and fork on Win32 + if (process.platform === 'win32') { + options.shell = false; + } + return spawn(options.execPath, args, options); }; From ee7a941015730e01792c55815a8e9cf602d203f9 Mon Sep 17 00:00:00 2001 From: Alex Gresnel <31708810+agresnel@users.noreply.github.com> Date: Sat, 9 Sep 2017 15:27:30 -0700 Subject: [PATCH 2/4] Create test-child-process-fork-noshell.js Test for https://github.com/nodejs/node/pull/15299 --- .../test-child-process-fork-noshell.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/parallel/test-child-process-fork-noshell.js diff --git a/test/parallel/test-child-process-fork-noshell.js b/test/parallel/test-child-process-fork-noshell.js new file mode 100644 index 00000000000000..b88a2e71e3e997 --- /dev/null +++ b/test/parallel/test-child-process-fork-noshell.js @@ -0,0 +1,29 @@ +// 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. + +'use strict'; +require('../common'); +const child_process = require('child_process'); +const fixtures = require('../common/fixtures'); + +//As per: https://github.com/nodejs/node/issues/13983 should produce no error output + +child_process.fork(fixtures.path('empty.js'), { shell: true }); From 2248edbb6c10e016f1a7212e538615309b272570 Mon Sep 17 00:00:00 2001 From: Alex Gresnel <31708810+agresnel@users.noreply.github.com> Date: Sat, 9 Sep 2017 21:06:53 -0700 Subject: [PATCH 3/4] Update child_process.js --- lib/child_process.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index b3df6f141a6d2e..870e603a11e1d5 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -94,10 +94,8 @@ exports.fork = function(modulePath /*, args, options*/) { options.execPath = options.execPath || process.execPath; - // Make sure we don't try to shell and fork on Win32 - if (process.platform === 'win32') { - options.shell = false; - } + // Make sure we don't try to open a shell when we fork + options.shell = false; return spawn(options.execPath, args, options); }; From a35f2f9febd26266d7a24787761a1565c7d2bc72 Mon Sep 17 00:00:00 2001 From: Alex Gresnel <31708810+agresnel@users.noreply.github.com> Date: Sat, 9 Sep 2017 21:25:40 -0700 Subject: [PATCH 4/4] Documentation update #13983 --- doc/api/child_process.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index f4a843fc0966ad..5bba32f240571e 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -335,7 +335,7 @@ The `child_process.fork()` method is a special case of Like [`child_process.spawn()`][], a [`ChildProcess`][] object is returned. The returned [`ChildProcess`][] will have an additional communication channel built-in that allows messages to be passed back and forth between the parent and child. See -[`subprocess.send()`][] for details. +[`subprocess.send()`][] for details. It is important to keep in mind that spawned Node.js child processes are independent of the parent with exception of the IPC communication channel @@ -356,6 +356,9 @@ output on this fd is expected to be line delimited JSON objects. *Note*: Unlike the fork(2) POSIX system call, `child_process.fork()` does not clone the current process. +*Note*: The `shell` option available in [`child_process.spawn()`][] is not +supported by `child_process.fork()` and will be ignored if set. + ### child_process.spawn(command[, args][, options])