fix process.exit and uncaughtException code.

This commit is contained in:
Christopher Jeffrey 2014-09-18 14:54:08 -07:00
parent 84ea0890a8
commit 1f0413e262
1 changed files with 10 additions and 3 deletions

View File

@ -47,15 +47,22 @@ Bitcoin.prototype.start = function(callback) {
process.exit = function(code) {
exitCaught = code || 0;
if (!self._shutdown) {
return self._exit(exitCaught);
return self._exit(code);
}
self.stop();
};
process.on('uncaughtException', function(err) {
if (process.listeners('uncaughtException').length > 1) {
return;
}
errorCaught = err;
if (!self._shutdown) {
return self._exit(exitCaught !== none ? exitCaught : 1);
if (err && err.stack) {
console.error(err.stack);
}
self._exit(1);
return;
}
self.stop();
});
@ -91,7 +98,7 @@ Bitcoin.prototype.start = function(callback) {
}
if (errorCaught !== none) {
if (errorCaught.stack) {
if (errorCaught && errorCaught.stack) {
console.error(errorCaught.stack);
}
return self._exit(0);