Skip to content

Commit

Permalink
doc: add example of event close for child_process
Browse files Browse the repository at this point in the history
PR-URL: #28376
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
ltciro authored and Trott committed Jul 30, 2019
1 parent b04de23 commit 89344f5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,23 @@ The `'close'` event is emitted when the stdio streams of a child process have
been closed. This is distinct from the [`'exit'`][] event, since multiple
processes might share the same stdio streams.

```js
const { spawn } = require('child_process');
const ls = spawn('ls', ['-lh', '/usr']);

ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});

ls.on('close', (code) => {
console.log(`child process close all stdio with code ${code}`);
});

ls.on('exit', (code) => {
console.log(`child process exited with code ${code}`);
});
```

### Event: 'disconnect'
<!-- YAML
added: v0.7.2
Expand Down

0 comments on commit 89344f5

Please sign in to comment.