diff --git a/lib/interrupt.js b/lib/interrupt.js index 0858e67..4c910d3 100644 --- a/lib/interrupt.js +++ b/lib/interrupt.js @@ -27,7 +27,10 @@ class Interrupt extends EventEmitter { this.dbt = opts.debounce ? opts.debounce : 200 this.poller = new Epoll( debounce((err, fd, events) => { - if (err) { this.emit('error', err) } else { this.clear().then(this.emit('fired', this.hook)) } + if (err) { this.emit('error', err) } else { + // this.clear().then(this.emit('fired', this.hook)) + this.emit('fired', this.hook) + } }, this.dbt, true) // true = leading ) } @@ -36,6 +39,7 @@ class Interrupt extends EventEmitter { process.on('SIGINT', () => { this.exit().then((resp) => console.log("\n", resp)) // unexport on cntrl-c + .catch(err => console.log("error:", err)) }) return _.pSeries([ @@ -81,7 +85,11 @@ class Interrupt extends EventEmitter { } start() { - this.clear().then(() => this.poller.add(this.valuefd, Epoll.EPOLLPRI)); + this.clear().then(() => this.poller.add(this.valuefd, Epoll.EPOLLPRI | Epoll.EPOLLONESHOT)); + } + + reset() { + this.clear().then(() => this.poller.modify(this.valuefd, Epoll.EPOLLPRI | Epoll.EPOLLONESHOT)); } stop() {