diff options
author | Laura Ciro <ltciro@gmail.com> | 2019-06-21 17:55:37 -0500 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-30 06:19:21 -0700 |
commit | 89344f5bee0dc566e5990c9618efbb73d6a9284d (patch) | |
tree | 16a341ea3187d1d96430c2557f84c9e1e451c1b6 /doc/api/child_process.md | |
parent | b04de23afa6da18d7b81b70c1a4bb53476f125c7 (diff) | |
download | android-node-v8-89344f5bee0dc566e5990c9618efbb73d6a9284d.tar.gz android-node-v8-89344f5bee0dc566e5990c9618efbb73d6a9284d.tar.bz2 android-node-v8-89344f5bee0dc566e5990c9618efbb73d6a9284d.zip |
doc: add example of event close for child_process
PR-URL: https://github.com/nodejs/node/pull/28376
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc/api/child_process.md')
-rw-r--r-- | doc/api/child_process.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 2c829fa157..7945c93bf0 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -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 |