UNPKG

5.11 kBMarkdownView Raw
1[![Codecov](https://img.shields.io/codecov/c/github/ehmicky/human-signals.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/human-signals)
2[![Travis](https://img.shields.io/badge/cross-platform-4cc61e.svg?logo=travis)](https://travis-ci.org/ehmicky/human-signals)
3[![Node](https://img.shields.io/node/v/human-signals.svg?logo=node.js)](https://www.npmjs.com/package/human-signals)
4[![Gitter](https://img.shields.io/gitter/room/ehmicky/human-signals.svg?logo=gitter)](https://gitter.im/ehmicky/human-signals)
5[![Twitter](https://img.shields.io/badge/%E2%80%8B-twitter-4cc61e.svg?logo=twitter)](https://twitter.com/intent/follow?screen_name=ehmicky)
6[![Medium](https://img.shields.io/badge/%E2%80%8B-medium-4cc61e.svg?logo=medium)](https://medium.com/@ehmicky)
7
8Human-friendly process signals.
9
10This is a map of known process signals with some information about each signal.
11
12Unlike
13[`os.constants.signals`](https://nodejs.org/api/os.html#os_signal_constants)
14this includes:
15
16- human-friendly [descriptions](#description)
17- [default actions](#action), including whether they [can be prevented](#forced)
18- whether the signal is [supported](#supported) by the current OS
19
20# Example
21
22```js
23const { signalsByName, signalsByNumber } = require('human-signals')
24
25console.log(signalsByName.SIGINT)
26// {
27// name: 'SIGINT',
28// number: 2,
29// description: 'User interruption with CTRL-C',
30// supported: true,
31// action: 'terminate',
32// forced: false,
33// standard: 'ansi'
34// }
35
36console.log(signalsByNumber[8])
37// {
38// name: 'SIGFPE',
39// number: 8,
40// description: 'Floating point arithmetic error',
41// supported: true,
42// action: 'core',
43// forced: false,
44// standard: 'ansi'
45// }
46```
47
48# Install
49
50```bash
51npm install human-signals
52```
53
54# Usage
55
56## signalsByName
57
58_Type_: `object`
59
60Object whose keys are signal [names](#name) and values are
61[signal objects](#signal).
62
63## signalsByNumber
64
65_Type_: `object`
66
67Object whose keys are signal [numbers](#number) and values are
68[signal objects](#signal).
69
70## signal
71
72_Type_: `object`
73
74Signal object with the following properties.
75
76### name
77
78_Type_: `string`
79
80Standard name of the signal, for example `'SIGINT'`.
81
82### number
83
84_Type_: `number`
85
86Code number of the signal, for example `2`. While most `number` are
87cross-platform, some are different between different OS.
88
89### description
90
91_Type_: `string`
92
93Human-friendly description for the signal, for example
94`'User interruption with CTRL-C'`.
95
96### supported
97
98_Type_: `boolean`
99
100Whether the current OS can handle this signal in Node.js using
101[`process.on(name, handler)`](https://nodejs.org/api/process.html#process_signal_events).
102
103The list of supported signals
104[is OS-specific](https://github.com/ehmicky/cross-platform-node-guide/blob/master/docs/6_networking_ipc/signals.md#cross-platform-signals).
105
106### action
107
108_Type_: `string`\
109_Enum_: `'terminate'`, `'core'`, `'ignore'`, `'pause'`, `'unpause'`
110
111What is the default action for this signal when it is not handled.
112
113### forced
114
115_Type_: `boolean`
116
117Whether the signal's default action cannot be prevented. This is `true` for
118`SIGTERM`, `SIGKILL` and `SIGSTOP`.
119
120### standard
121
122_Type_: `string`\
123_Enum_: `'ansi'`, `'posix'`, `'bsd'`, `'systemv'`, `'other'`
124
125Which standard defined that signal.
126
127# Support
128
129If you found a bug or would like a new feature, _don't hesitate_ to
130[submit an issue on GitHub](../../issues).
131
132For other questions, feel free to
133[chat with us on Gitter](https://gitter.im/ehmicky/human-signals).
134
135Everyone is welcome regardless of personal background. We enforce a
136[Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and
137inclusive environment.
138
139# Contributing
140
141This project was made with ❤️. The simplest way to give back is by starring and
142sharing it online.
143
144If the documentation is unclear or has a typo, please click on the page's `Edit`
145button (pencil icon) and suggest a correction.
146
147If you would like to help us fix a bug or add a new feature, please check our
148[guidelines](CONTRIBUTING.md). Pull requests are welcome!
149
150Thanks go to our wonderful contributors:
151
152<!-- ALL-CONTRIBUTORS-LIST:START -->
153<!-- prettier-ignore-start -->
154<!-- markdownlint-disable -->
155<table>
156 <tr>
157 <td align="center"><a href="https://twitter.com/ehmicky"><img src="https://avatars2.githubusercontent.com/u/8136211?v=4" width="100px;" alt=""/><br /><sub><b>ehmicky</b></sub></a><br /><a href="https://github.com/ehmicky/human-signals/commits?author=ehmicky" title="Code">💻</a> <a href="#design-ehmicky" title="Design">🎨</a> <a href="#ideas-ehmicky" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ehmicky/human-signals/commits?author=ehmicky" title="Documentation">📖</a></td>
158 <td align="center"><a href="http://www.electrovir.com"><img src="https://avatars0.githubusercontent.com/u/1205860?v=4" width="100px;" alt=""/><br /><sub><b>electrovir</b></sub></a><br /><a href="https://github.com/ehmicky/human-signals/commits?author=electrovir" title="Code">💻</a></td>
159 </tr>
160</table>
161
162<!-- markdownlint-enable -->
163<!-- prettier-ignore-end -->
164
165<!-- ALL-CONTRIBUTORS-LIST:END -->