Skip to content

SIGTERM handler does not run if there are no tasks running and exit code is always 0 #28502

Description

@TrevorSundberg
  • Version: v11.15.0
  • Platform: Linux tsundberg-dev 4.18.0-20-generic add issue contributing section #21~18.04.1-Ubuntu SMP Wed May 8 08:43:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: process

To run the following tests paste them into index.js and run node index.js; echo $?


Case 1

The following results in an expected output:

process.kill(process.pid, 'SIGTERM')

Output:

Terminated
143

Case 2

Adding a SIGTERM results in an exit code of 0, and the handler never runs:

process.on('SIGTERM', () => {
    console.error('Handle ran!')
    process.exit(1)
})

process.kill(process.pid, 'SIGTERM')

Output:

0

Case 3

Adding a timeout or some other task that keeps node alive results in the expected behavior:

process.on('SIGTERM', () => {
    console.error('Handle ran!')
    process.exit(1)
})

process.kill(process.pid, 'SIGTERM')

setTimeout(() => {}, 100000)

Output:

Handle ran!
1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.processIssues and PRs related to the process subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions