mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-03 14:45:33 +00:00
automatically deal with custom process events. fixes #100.
This commit is contained in:
parent
127ae12c1b
commit
27060d59af
@ -360,16 +360,25 @@ function Screen(options) {
|
||||
|
||||
this._maxListeners = Infinity;
|
||||
|
||||
if (this.options.handleUncaughtExceptions !== false) {
|
||||
process.on('uncaughtException', function(err) {
|
||||
reset();
|
||||
if (err) console.error(err.stack ? err.stack + '' : err + '');
|
||||
return process.exit(1);
|
||||
});
|
||||
}
|
||||
Screen.total++;
|
||||
|
||||
process.on('SIGTERM', function() {
|
||||
return process.exit(0);
|
||||
process.on('uncaughtException', function(err) {
|
||||
if (process.listeners('uncaughtException').length > Screen.total) {
|
||||
return;
|
||||
}
|
||||
reset();
|
||||
err = err || new Error('Uncaught Exception.');
|
||||
console.error(err.stack ? err.stack + '' : err + '');
|
||||
return process.exit(1);
|
||||
});
|
||||
|
||||
['SIGTERM', 'SIGINT', 'SIGQUIT'].forEach(function(signal) {
|
||||
process.on(signal, function() {
|
||||
if (process.listeners(signal).length > Screen.total) {
|
||||
return;
|
||||
}
|
||||
return process.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
@ -398,6 +407,8 @@ function Screen(options) {
|
||||
|
||||
Screen.global = null;
|
||||
|
||||
Screen.total = 0;
|
||||
|
||||
Screen.prototype.__proto__ = Node.prototype;
|
||||
|
||||
Screen.prototype.type = 'screen';
|
||||
|
Loading…
x
Reference in New Issue
Block a user