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>
This commit is contained in:
parent
b04de23afa
commit
89344f5bee
@ -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
|
been closed. This is distinct from the [`'exit'`][] event, since multiple
|
||||||
processes might share the same stdio streams.
|
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'
|
### Event: 'disconnect'
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v0.7.2
|
added: v0.7.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user