signal-exit
when you want to fire an event no matter how a process exits.
Last updated 9 years ago by bcoe .
ISC · Repository · Bugs · Original npm
$ cnpm install signal-exit 
SYNC missed versions from official npm registry.

signal-exit

Build Status Coverage NPM version Standard Version

When you want to fire an event no matter how a process exits:

  • reaching the end of execution.
  • explicitly having process.exit(code) called.
  • having process.kill(pid, sig) called.
  • receiving a fatal signal from outside the process

Use signal-exit.

var onExit = require('signal-exit')

onExit(function (code, signal) {
  console.log('process exited!')
})

API

var remove = onExit(function (code, signal) {}, options)

The return value of the function is a function that will remove the handler.

Note that the function only fires for signals if the signal would cause the proces to exit. That is, there are no other listeners, and it is a fatal signal.

Options

  • alwaysLast: Run this handler after any other signal or exit handlers. This causes process.emit to be monkeypatched.

Current Tags

  • 4.0.2                                ...           latest (2 years ago)
  • 3.0.1                                ...           next (9 years ago)

6 Versions

  • 4.0.2                                ...           2 years ago
  • 4.0.1                                ...           2 years ago
  • 3.0.7                                ...           4 years ago
  • 3.0.6                                ...           4 years ago
  • 3.0.1                                ...           9 years ago
  • 3.0.3                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (6)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org