question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SIGINT handlers defined in app are not executed

See original GitHub issue

Operating 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:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:6

github_iconTop GitHub Comments

4reactions
alubbecommented, Sep 25, 2019

sounds good - how about merging https://github.com/raszi/node-tmp/pull/193 ?

1reaction
eugene1gcommented, Sep 8, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found