README.md (5672B)
1 [](https://www.npmjs.com/package/human-signals) 2 [](/src/main.d.ts) 3 [](https://codecov.io/gh/ehmicky/human-signals) 4 [](https://fosstodon.org/@ehmicky) 5 [](https://medium.com/@ehmicky) 6 7 Human-friendly process signals. 8 9 This is a map of known process signals with some information about each signal. 10 11 Unlike 12 [`os.constants.signals`](https://nodejs.org/api/os.html#os_signal_constants) 13 this includes: 14 15 - human-friendly [descriptions](#description) 16 - [default actions](#action), including whether they [can be prevented](#forced) 17 - whether the signal is [supported](#supported) by the current OS 18 19 # Hire me 20 21 Please 22 [reach out](https://www.linkedin.com/feed/update/urn:li:activity:7018596298127781890/) 23 if you're looking for a Node.js API or CLI engineer (10 years of experience). 24 Most recently I have been [Netlify Build](https://github.com/netlify/build)'s 25 and [Netlify Plugins](https://www.netlify.com/products/build/plugins/)' 26 technical lead for 2.5 years. I am available for full-time remote positions in 27 either US or EU time zones. 28 29 # Example 30 31 ```js 32 import { signalsByName, signalsByNumber } from 'human-signals' 33 34 console.log(signalsByName.SIGINT) 35 // { 36 // name: 'SIGINT', 37 // number: 2, 38 // description: 'User interruption with CTRL-C', 39 // supported: true, 40 // action: 'terminate', 41 // forced: false, 42 // standard: 'ansi' 43 // } 44 45 console.log(signalsByNumber[8]) 46 // { 47 // name: 'SIGFPE', 48 // number: 8, 49 // description: 'Floating point arithmetic error', 50 // supported: true, 51 // action: 'core', 52 // forced: false, 53 // standard: 'ansi' 54 // } 55 ``` 56 57 # Install 58 59 ```bash 60 npm install human-signals 61 ``` 62 63 This package works in Node.js >=14.18.0. 64 65 This is an ES module. It must be loaded using 66 [an `import` or `import()` statement](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c), 67 not `require()`. If TypeScript is used, it must be configured to 68 [output ES modules](https://www.typescriptlang.org/docs/handbook/esm-node.html), 69 not CommonJS. 70 71 # Usage 72 73 ## signalsByName 74 75 _Type_: `object` 76 77 Object whose keys are signal [names](#name) and values are 78 [signal objects](#signal). 79 80 ## signalsByNumber 81 82 _Type_: `object` 83 84 Object whose keys are signal [numbers](#number) and values are 85 [signal objects](#signal). 86 87 ## signal 88 89 _Type_: `object` 90 91 Signal object with the following properties. 92 93 ### name 94 95 _Type_: `string` 96 97 Standard name of the signal, for example `'SIGINT'`. 98 99 ### number 100 101 _Type_: `number` 102 103 Code number of the signal, for example `2`. While most `number` are 104 cross-platform, some are different between different OS. 105 106 ### description 107 108 _Type_: `string` 109 110 Human-friendly description for the signal, for example 111 `'User interruption with CTRL-C'`. 112 113 ### supported 114 115 _Type_: `boolean` 116 117 Whether the current OS can handle this signal in Node.js using 118 [`process.on(name, handler)`](https://nodejs.org/api/process.html#process_signal_events). 119 120 The list of supported signals 121 [is OS-specific](https://github.com/ehmicky/cross-platform-node-guide/blob/main/docs/6_networking_ipc/signals.md#cross-platform-signals). 122 123 ### action 124 125 _Type_: `string`\ 126 _Enum_: `'terminate'`, `'core'`, `'ignore'`, `'pause'`, `'unpause'` 127 128 What is the default action for this signal when it is not handled. 129 130 ### forced 131 132 _Type_: `boolean` 133 134 Whether the signal's default action cannot be prevented. This is `true` for 135 `SIGTERM`, `SIGKILL` and `SIGSTOP`. 136 137 ### standard 138 139 _Type_: `string`\ 140 _Enum_: `'ansi'`, `'posix'`, `'bsd'`, `'systemv'`, `'other'` 141 142 Which standard defined that signal. 143 144 # Support 145 146 For any question, _don't hesitate_ to [submit an issue on GitHub](../../issues). 147 148 Everyone is welcome regardless of personal background. We enforce a 149 [Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and 150 inclusive environment. 151 152 # Contributing 153 154 This project was made with ❤️. The simplest way to give back is by starring and 155 sharing it online. 156 157 If the documentation is unclear or has a typo, please click on the page's `Edit` 158 button (pencil icon) and suggest a correction. 159 160 If you would like to help us fix a bug or add a new feature, please check our 161 [guidelines](CONTRIBUTING.md). Pull requests are welcome! 162 163 Thanks go to our wonderful contributors: 164 165 <!-- ALL-CONTRIBUTORS-LIST:START --> 166 <!-- prettier-ignore-start --> 167 <!-- markdownlint-disable --> 168 <table> 169 <tr> 170 <td align="center"><a href="https://fosstodon.org/@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> 171 <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> 172 </tr> 173 </table> 174 175 <!-- markdownlint-enable --> 176 <!-- prettier-ignore-end --> 177 178 <!-- ALL-CONTRIBUTORS-LIST:END -->