Sha256: db39d4c491934af970ebdfaa7d49808e2a153c8cd86bef3129a7477838b9c930

Contents?: true

Size: 1.46 KB

Versions: 113

Compression:

Stored size: 1.46 KB

Contents

# signal-exit

[![Build Status](https://travis-ci.org/tapjs/signal-exit.png)](https://travis-ci.org/tapjs/signal-exit)
[![Coverage](https://coveralls.io/repos/tapjs/signal-exit/badge.svg?branch=master)](https://coveralls.io/r/tapjs/signal-exit?branch=master)
[![NPM version](https://img.shields.io/npm/v/signal-exit.svg)](https://www.npmjs.com/package/signal-exit)
[![Windows Tests](https://img.shields.io/appveyor/ci/bcoe/signal-exit/master.svg?label=Windows%20Tests)](https://ci.appveyor.com/project/bcoe/signal-exit)
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/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`.

```js
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.

Version data entries

113 entries across 81 versions & 15 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/fsevents/node_modules/signal-exit/README.md
disco_app-0.18.0 test/dummy/node_modules/signal-exit/README.md
disco_app-0.18.2 test/dummy/node_modules/signal-exit/README.md
disco_app-0.16.1 test/dummy/node_modules/signal-exit/README.md
disco_app-0.15.2 test/dummy/node_modules/signal-exit/README.md
disco_app-0.18.4 test/dummy/node_modules/signal-exit/README.md
disco_app-0.18.1 test/dummy/node_modules/signal-exit/README.md
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/signal-exit/README.md
disco_app-0.14.0 test/dummy/node_modules/signal-exit/README.md
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/signal-exit/README.md
enju_library-0.3.8 spec/dummy/node_modules/fsevents/node_modules/signal-exit/README.md
enju_library-0.3.8 spec/dummy/node_modules/signal-exit/README.md
ilog-0.4.1 node_modules/fsevents/node_modules/signal-exit/README.md
ilog-0.4.1 node_modules/signal-exit/README.md
ilog-0.4.0 node_modules/signal-exit/README.md
ilog-0.4.0 node_modules/fsevents/node_modules/signal-exit/README.md
ilog-0.3.3 node_modules/fsevents/node_modules/signal-exit/README.md
ilog-0.3.3 node_modules/signal-exit/README.md
jester-data-8.0.0 node_modules/signal-exit/README.md
jester-data-8.0.0 node_modules/fsevents/node_modules/signal-exit/README.md