diff options
author | isaacs <i@izs.me> | 2013-02-18 11:24:14 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-18 11:24:14 -0800 |
commit | 75df612cd7eb282c4d618b8018036a39b8941db9 (patch) | |
tree | 7685519cd44a6c61fc6eb7068af3ecdc3b14086c /doc | |
parent | 09b1212254445d1848e369462d3f91fb1c3f3cf4 (diff) | |
download | node-new-75df612cd7eb282c4d618b8018036a39b8941db9.tar.gz |
doc: Use 'close' rather than 'exit' in spawn examples
Close #4515
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/child_process.markdown | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index cc82adc535..bd04e0e298 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -41,6 +41,10 @@ See `waitpid(2)`. ### Event: 'close' +* `code` {Number} the exit code, if it exited normally. +* `signal` {String} the signal passed to kill the child process, if it + was killed by the parent. + This event is emitted when the stdio streams of a child process have all terminated. This is distinct from 'exit', since multiple processes might share the same stdio streams. @@ -112,7 +116,7 @@ be sent `'SIGTERM'`. See `signal(7)` for a list of available signals. var spawn = require('child_process').spawn, grep = spawn('grep', ['ssh']); - grep.on('exit', function (code, signal) { + grep.on('close', function (code, signal) { console.log('child process terminated due to receipt of signal '+signal); }); @@ -279,7 +283,7 @@ Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the exit cod console.log('stderr: ' + data); }); - ls.on('exit', function (code) { + ls.on('close', function (code) { console.log('child process exited with code ' + code); }); @@ -298,7 +302,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 +317,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); } |