### 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.
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);
});
console.log('stderr: ' + data);
});
- ls.on('exit', function (code) {
+ ls.on('close', function (code) {
console.log('child process exited with code ' + code);
});
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);
}
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);
}