Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Rename spawnNode to fork
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed May 11, 2011
1 parent 7ea7094 commit 337c48d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/api/child_processes.markdown
Expand Up @@ -179,7 +179,7 @@ amount of data allowed on stdout or stderr - if this value is exceeded then
the child process is killed.


### child_process.spawnNode(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
Expand All @@ -191,7 +191,7 @@ For example:

var cp = require('child_process');

var n = cp.spawnNode(__dirname + '/sub.js');
var n = cp.fork(__dirname + '/sub.js');

n.on('message', function(m) {
console.log('PARENT got message:', m);
Expand Down
4 changes: 2 additions & 2 deletions lib/child_process.js
Expand Up @@ -59,7 +59,7 @@ function setupChannel(target, fd) {
}


exports.spawnNode = function(modulePath, args, options) {
exports.fork = function(modulePath, args, options) {
if (!options) options = {};
options.wantChannel = true;

Expand All @@ -81,7 +81,7 @@ exports.spawnNode = function(modulePath, args, options) {
};


exports._spawnNodeChild = function(fd) {
exports._forkChild = function(fd) {
setupChannel(process, fd);
};

Expand Down
2 changes: 1 addition & 1 deletion src/node.js
Expand Up @@ -317,7 +317,7 @@
var fd = parseInt(process.env.NODE_CHANNEL_FD);
assert(fd >= 0);
var cp = NativeModule.require('child_process');
cp._spawnNodeChild(fd);
cp._forkChild(fd);
assert(process.send);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_child_process.cc
Expand Up @@ -345,7 +345,7 @@ int ChildProcess::Spawn(const char *file,
}


// The channel will be used by spawnNode() for a little JSON channel.
// The channel will be used by js-land "fork()" for a little JSON channel.
// The pointer is used to pass one end of the socket pair back to the
// parent.
// channel_fds[0] is for the parent
Expand Down
4 changes: 2 additions & 2 deletions test/simple/test-child-process-spawn-node.js
@@ -1,8 +1,8 @@
var assert = require('assert');
var common = require('../common');
var spawnNode = require('child_process').spawnNode;
var fork = require('child_process').fork;

var n = spawnNode(common.fixturesDir + '/child-process-spawn-node.js');
var n = fork(common.fixturesDir + '/child-process-spawn-node.js');

var messageCount = 0;

Expand Down

3 comments on commit 337c48d

@felixge
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that confusing with respect to the actual fork() sys call?

@ry
Copy link
Author

@ry ry commented on 337c48d May 12, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought originally but the unix-y people at Joyent don't mind. "Fork" is cute.

@felixge
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cute indeed. Just brings back sad memories of having my actual fork patch rejected ; )

Please sign in to comment.