Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use close event instead of exit in child_process example. #4515

Closed
wants to merge 1 commit into from

3 participants

@glasser

Node doesn't guarantee that all the data will be read from the 'ps' before its
'exit' event is called, so the example is misleading.

(I suppose this really should be rewritten to use streams2, but this is at least an incremental improvement. I found a real bug in my code today that was modeled after this example and assuming that 'exit' came after all stdout 'data'.)

@bnoordhuis

The PR itself mostly LGTM but please see CONTRIBUTING: we need a signed CLA and the commit log should be reworded a little.

@glasser glasser Use 'close' event in child_process example.
Node doesn't guarantee that all the data will be read from the 'ps'
before its 'exit' event is called, so the example is misleading.
9c9d898
@bnoordhuis

@glasser If you sign the CLA, I'll land it. (If not, I guess I'll close the PR.)

@isaacs isaacs closed this in 75df612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 3, 2013
  1. @glasser

    Use 'close' event in child_process example.

    glasser authored
    Node doesn't guarantee that all the data will be read from the 'ps'
    before its 'exit' event is called, so the example is misleading.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 doc/api/child_process.markdown
View
4 doc/api/child_process.markdown
@@ -298,7 +298,7 @@ Example: A very elaborate way to run 'ps ax | grep ssh'
console.log('ps stderr: ' + data);
});
- ps.on('exit', function (code) {
+ ps.on('close', function (code) {
if (code !== 0) {
console.log('ps process exited with code ' + code);
}
@@ -313,7 +313,7 @@ Example: A very elaborate way to run 'ps ax | grep ssh'
console.log('grep stderr: ' + data);
});
- grep.on('exit', function (code) {
+ grep.on('close', function (code) {
if (code !== 0) {
console.log('grep process exited with code ' + code);
}
Something went wrong with that request. Please try again.