Browse Source

Allow calling fork() without args or options

Closes GH-2424
v0.7.4-release
Andreas Madsen 13 years ago
committed by Bert Belder
parent
commit
70884875c9
  1. 2
      doc/api/child_processes.markdown
  2. 16
      lib/child_process.js

2
doc/api/child_processes.markdown

@ -198,7 +198,7 @@ subshell but rather the specified file directly. This makes it slightly
leaner than `child_process.exec`. It has the same options.
### child_process.fork(modulePath, arguments, options)
### child_process.fork(modulePath, [arguments], [options])
This is a special case of the `spawn()` functionality for spawning Node
processes. In addition to having all the methods in a normal ChildProcess

16
lib/child_process.js

@ -160,13 +160,23 @@ function setupChannel(target, channel) {
function nop() { }
exports.fork = function(modulePath /*, args, options*/) {
exports.fork = function(modulePath, args, options) {
if (!options) options = {};
// Get options and args arguments.
var options, args;
if (Array.isArray(arguments[1])) {
args = arguments[1];
options = arguments[2] || {};
} else {
args = [];
options = arguments[1] || {};
}
args = args ? args.slice(0) : [];
// Copy args and add modulePath
args = args.slice(0);
args.unshift(modulePath);
// Don't allow stdinStream and customFds since a stdin channel will be used
if (options.stdinStream) {
throw new Error('stdinStream not allowed for fork()');
}

Loading…
Cancel
Save