process: Add exitCode property

This allows one to set a specific status code, while still letting the
process exit gracefully once all async operations are completed.
This commit is contained in:
isaacs committed 2013-09-06 16:51:51 -07:00
1 parent b89b97dded
commit a5dba82ee2
4 files changed
+100 -3

No files matched your search

+6 -2
View File
@@ -545,12 +545,16 @@
};
startup.processKillAndExit = function() {
process.exitCode = 0;
process.exit = function(code) {
if (NativeModule.require('util').isNumber(code))
process.exitCode = code;
if (!process._exiting) {
process._exiting = true;
process.emit('exit', code || 0);
process.emit('exit', process.exitCode || 0);
}
process.reallyExit(code || 0);
process.reallyExit(process.exitCode || 0);
};
process.kill = function(pid, sig) {