Skip to content

Commit 08c83bb

Browse files
committed
Merge remote-tracking branch 'upstream/v0.10'
2 parents bddea03 + 5a8de85 commit 08c83bb

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

doc/api/child_process.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ And then the child script, `'sub.js'` might look like this:
194194
In the child the `process` object will have a `send()` method, and `process`
195195
will emit objects each time it receives a message on its channel.
196196

197+
Please note that the `send()` method on both the parent and child are
198+
synchronous - sending large chunks of data is not advised (pipes can be used
199+
instead, see
200+
[`child_process.spawn`](#child_process_child_process_spawn_command_args_options)).
201+
197202
There is a special case when sending a `{cmd: 'NODE_foo'}` message. All messages
198203
containing a `NODE_` prefix in its `cmd` property will not be emitted in
199204
the `message` event, since they are internal messages used by node core.

doc/api/process.markdown

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,21 @@ cases:
5252

5353
## Event: 'exit'
5454

55-
Emitted when the process is about to exit. This is a good hook to perform
56-
constant time checks of the module's state (like for unit tests). The main
57-
event loop will no longer be run after the 'exit' callback finishes, so
58-
timers may not be scheduled.
55+
Emitted when the process is about to exit. There is no way to prevent the
56+
exiting of the event loop at this point, and once all `exit` listeners have
57+
finished running the process will exit. Therefore you **must** only perform
58+
**synchronous** operations in this handler. This is a good hook to perform
59+
checks on the module's state (like for unit tests). The callback takes one
60+
argument, the code the process is exiting with.
5961

6062
Example of listening for `exit`:
6163

62-
process.on('exit', function() {
64+
process.on('exit', function(code) {
65+
// do *NOT* do this
6366
setTimeout(function() {
6467
console.log('This will not run');
6568
}, 0);
66-
console.log('About to exit.');
69+
console.log('About to exit with code:', code);
6770
});
6871

6972
## Event: 'uncaughtException'

0 commit comments

Comments
 (0)