SIGINT handlers defined in app are not executed
See original GitHub issueOperating System
- MacOS
- Linux
NodeJS Version
- 10.15.3
Tmp Version
- 0.1.0
Expected Behavior
Allow executing app defined SIGINT handlers
Experienced Behavior
App exits before custom handlers are executed.
Here is the reason: https://github.com/raszi/node-tmp/blob/master/lib/tmp.js#L635 Code to reproduce:
const tmp = require('tmp');
console.log(`Run from terminal: kill -SIGINT ${process.pid}`);
process.on('SIGINT', () => {
console.log('Custom SIGINT handler - do some clean up')
process.exit(0);
});
setTimeout(() => {}, 100000)
Custom SIGINT handler - do some clean up not printed.
The same code works OK with tmp@0.0.33
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:6
Top Results From Across the Web
SIGINT handler in NodeJS app not called for ctrl-C (Mac)
I run the program from the command line, and while it is still running, press ctrl + C . I am immediately returned...
Read more >SIGINT handler runs only once - Unix & Linux Stack Exchange
several times and each time I send a SIGINT (using kill -INT $PID ) to execute the signal handler, which counts to 30....
Read more >signal — Set handlers for asynchronous events ... - Python Docs
Suspend execution of the calling thread until the delivery of one of the signals specified in the signal set sigset. The function accepts...
Read more >Signals (Debugging with GDB) - sourceware.org
If a signal that has handle nostop and handle pass set arrives while a stepping command (e.g., stepi , step , next )...
Read more >7 Handle Signals and Exceptions - Java
If an application must register its own console handler, then the -Xrs option can be used. With this option, shutdown hooks are not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
sounds good - how about merging https://github.com/raszi/node-tmp/pull/193 ?
There is also the case of async handlers - we have process.on() handlers that return promise, and NodeJS will wait for those promises to resolve before existing. As I understand https://github.com/raszi/node-tmp/commit/df8df51ce4d5272c4bafb3bcfa394ec22fffb6a3, it will call original handlers in a sync matter, which will not give async functions enough time to complete.