mirror of
https://github.com/chjj/blessed.git
synced 2026-02-06 13:36:46 +00:00
clean up process events.
This commit is contained in:
parent
27060d59af
commit
a9153aeef5
@ -17,6 +17,8 @@ var colors = require('./colors')
|
||||
, program = require('./program')
|
||||
, widget = exports;
|
||||
|
||||
var nextTick = global.setImmediate || process.nextTick.bind(process);
|
||||
|
||||
/**
|
||||
* Node
|
||||
*/
|
||||
@ -352,12 +354,6 @@ function Screen(options) {
|
||||
|
||||
this.enter();
|
||||
|
||||
function reset() {
|
||||
if (reset.done) return;
|
||||
reset.done = true;
|
||||
self.leave();
|
||||
}
|
||||
|
||||
this._maxListeners = Infinity;
|
||||
|
||||
Screen.total++;
|
||||
@ -366,10 +362,12 @@ function Screen(options) {
|
||||
if (process.listeners('uncaughtException').length > Screen.total) {
|
||||
return;
|
||||
}
|
||||
reset();
|
||||
self.leave();
|
||||
err = err || new Error('Uncaught Exception.');
|
||||
console.error(err.stack ? err.stack + '' : err + '');
|
||||
return process.exit(1);
|
||||
nextTick(function() {
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
['SIGTERM', 'SIGINT', 'SIGQUIT'].forEach(function(signal) {
|
||||
@ -377,12 +375,14 @@ function Screen(options) {
|
||||
if (process.listeners(signal).length > Screen.total) {
|
||||
return;
|
||||
}
|
||||
return process.exit(0);
|
||||
nextTick(function() {
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
reset();
|
||||
self.leave();
|
||||
});
|
||||
|
||||
this.on('newListener', function fn(type) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user