diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index dd396fa246..9d9f9aa988 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 699f2d339b..03cd1bd396 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'