@@ -849,12 +849,17 @@ Child processes always have three streams associated with them. `child.stdin`,
849849
850850### Event: 'exit'
851851
852- ` function (code) {} `
852+ ` function (code, signal ) {} `
853853
854- This event is emitted after the child process ends. ` code ` is the final exit
855- code of the process. After this event is emitted, the ` 'output' ` and
856- ` 'error' ` callbacks will no longer be made.
854+ This event is emitted after the child process ends. If the process terminated
855+ normally, ` code ` is the final exit code of the process, otherwise ` null ` . If
856+ the process terminated due to receipt of a signal, ` signal ` is the string name
857+ of the signal, otherwise ` null ` .
857858
859+ After this event is emitted, the ` 'output' ` and ` 'error' ` callbacks will no
860+ longer be made.
861+
862+ See ` waitpid(2) `
858863
859864### child_process.spawn(command, args, env)
860865
@@ -906,8 +911,8 @@ be sent `'SIGTERM'`. See `signal(7)` for a list of available signals.
906911 spawn = require('child_process').spawn,
907912 grep = spawn('grep', ['ssh']);
908913
909- grep.addListener('exit', function (code) {
910- sys.puts('child process exited with code ' + code );
914+ grep.addListener('exit', function (code, signal ) {
915+ sys.puts('child process terminated due to receipt of signal '+signal );
911916 });
912917
913918 // send SIGHUP to process
@@ -1013,7 +1018,8 @@ output, and return it all in a callback.
10131018
10141019The callback gets the arguments ` (error, stdout, stderr) ` . On success, ` error `
10151020will be ` null ` . On error, ` error ` will be an instance of ` Error ` and ` err.code `
1016- will be the exit code of the child process.
1021+ will be the exit code of the child process, and ` err.signal ` will be set to the
1022+ signal that terminated the process.
10171023
10181024There is a second optional argument to specify several options. The default options are
10191025
0 commit comments