diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-12-31 14:57:46 -0800 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-12-31 14:57:46 -0800 |
commit | 08c83bb172ca963763ef5f53f113e925926a6d7f (patch) | |
tree | 39468bad5124368d22c8251af8cf8ca36a2920db | |
parent | bddea032b7f2b0f2854faa18855249286bd99428 (diff) | |
parent | 5a8de857f0bd05941f54b20415ab7c374c4b1720 (diff) | |
download | node-08c83bb172ca963763ef5f53f113e925926a6d7f.tar.gz |
Merge remote-tracking branch 'upstream/v0.10'
-rw-r--r-- | doc/api/child_process.markdown | 5 | ||||
-rw-r--r-- | doc/api/process.markdown | 15 |
2 files changed, 14 insertions, 6 deletions
diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index dd396fa24..9d9f9aa98 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -194,6 +194,11 @@ And then the child script, `'sub.js'` might look like this: 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. +Please note that the `send()` method on both the parent and child are +synchronous - sending large chunks of data is not advised (pipes can be used +instead, see +[`child_process.spawn`](#child_process_child_process_spawn_command_args_options)). + There is a special case when sending a `{cmd: 'NODE_foo'}` message. All messages containing a `NODE_` prefix in its `cmd` property will not be emitted in the `message` event, since they are internal messages used by node core. diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 699f2d339..03cd1bd39 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -52,18 +52,21 @@ cases: ## Event: 'exit' -Emitted when the process is about to exit. This is a good hook to perform -constant time checks of the module's state (like for unit tests). The main -event loop will no longer be run after the 'exit' callback finishes, so -timers may not be scheduled. +Emitted when the process is about to exit. There is no way to prevent the +exiting of the event loop at this point, and once all `exit` listeners have +finished running the process will exit. Therefore you **must** only perform +**synchronous** operations in this handler. This is a good hook to perform +checks on the module's state (like for unit tests). The callback takes one +argument, the code the process is exiting with. Example of listening for `exit`: - process.on('exit', function() { + process.on('exit', function(code) { + // do *NOT* do this setTimeout(function() { console.log('This will not run'); }, 0); - console.log('About to exit.'); + console.log('About to exit with code:', code); }); ## Event: 'uncaughtException' |