镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

SIGINT handlers defined in app are not executed #192

Closed

Description

@alexandervain

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

Activity

  1. silkentrance commented on Apr 21, 2019

    @silkentrance
    Collaborator

    @alexandervain Very good find. This always went unnoticed in the tests as we do not have any custom SIGINT handlers installed. I wonder why the routine even checks the doExit parameter...
    I think that this can be removed completely.

  2. silkentrance commented on Apr 26, 2019

    @silkentrance
    Collaborator

    Ok, the doExit was there for a reason, having to do with jest and how it is managing its sandboxes, which eventually will run the initialising code of tmp multiple times.

    I think I have nailed it down and will prepare a PR now.

  3. added 2 commits that reference this issue on Apr 26, 2019
    ba683e1
    df8df51
  4. self-assigned this
    on Apr 26, 2019
  5. added a commit that references this issue on May 31, 2019
  6. alubbe commented on Jun 3, 2019

    @alubbe

    @alexandervain @papandreou Does this commit fix the bug? df8df51

  7. added a commit that references this issue on Jun 3, 2019
    9275e3e
  8. eugene1g commented on Sep 8, 2019

    @eugene1g

    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 df8df51, it will call original handlers in a sync matter, which will not give async functions enough time to complete.

  9. Tyler-Murphy commented on Sep 25, 2019

    @Tyler-Murphy

    @alubbe, I encountered the same bug while doing asynchronous operations in a SIGINT event listener. It was fixed by df8df51.

  10. alubbe commented on Sep 25, 2019

    @alubbe

    sounds good - how about merging #193 ?

  11. added a commit that references this issue on Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions