summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-05-11 00:41:16 -0700
committerRyan Dahl <ry@tinyclouds.org>2011-05-11 02:24:48 -0700
commit9e26dab150e15cdbc7fbec76dcadeafed7d85646 (patch)
treec1babf86ce7350080edc98662eba301448b6e796 /doc
parent205b9beb6be0d563a85027158e8af3bee8472b9e (diff)
downloadandroid-node-v8-9e26dab150e15cdbc7fbec76dcadeafed7d85646.tar.gz
android-node-v8-9e26dab150e15cdbc7fbec76dcadeafed7d85646.tar.bz2
android-node-v8-9e26dab150e15cdbc7fbec76dcadeafed7d85646.zip
child_process.spawnNode
For making easy worker processes.
Diffstat (limited to 'doc')
-rw-r--r--doc/api/child_processes.markdown33
1 files changed, 33 insertions, 0 deletions
diff --git a/doc/api/child_processes.markdown b/doc/api/child_processes.markdown
index b30de4bf27..3aa2a106a9 100644
--- a/doc/api/child_processes.markdown
+++ b/doc/api/child_processes.markdown
@@ -179,6 +179,39 @@ 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)
+
+This is a special case of the `spawn()` functionality for spawning Node
+processes. In addition to having all the methods in a normal ChildProcess
+instance, the returned object, has a communication channel built-in. The
+channel is written to with `child.send(message)` and messages are recieved
+by a `'message'` event on the child.
+
+For example:
+
+ var n = spawnNode(__dirname + '/sub.js');
+
+ n.on('message', function(m) {
+ console.log('PARENT got message:', m);
+ });
+
+ n.send({ hello: 'world' });
+
+And then the child script, `'sub.js'` would might look like this:
+
+ process.on('message', function(m) {
+ console.log('CHILD got message:', m);
+ });
+
+ process.send({ foo: 'bar' });
+
+In the child the `process` object will have a `send()` method, and `process`
+will emit objects each time it receives a message on its channel.
+
+By default the spawned Node process will have the stdin, stdout, stderr associated
+with the parent's. This can be overridden by using the `customFds` option.
+
+
### child.kill(signal='SIGTERM')
Send a signal to the child process. If no argument is given, the process will