diff --git a/lib/bitcoind.js b/lib/bitcoind.js index fb515993..1cbe5f45 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -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);