Human-friendly process signals
The npm package "human-signals" is a highly valuable node module designed to provide human-friendly descriptions and additional information for standard system signals in a Node.js environment. Typically, developers working with process control in Node.js need to handle various signals such as SIGKILL, SIGTERM, etc., which can often appear cryptic or less informative especially to those new to backend development. "Human-signals" addresses this challenge by mapping these signals to more descriptive and easier-to-understand texts, thereby making the debugging and development process smoother and more intuitive.
To integrate "human-signals" into your Node.js projects, you can easily get started by running the command `npm install human-signals` in your project directory. This simple installation adds a powerful tool to your development toolkit, enabling you to fetch human-readable descriptions for system signals effortlessly. By incorporating "human-signals", developers can not only expedite their coding and debugging tasks but also enhance code readability and maintenance, making it easier for teams to collaborate and manage codebases that involve complex signal handling.
Moreover, the "human-signals" module supports TypeScript, which is a boon for developers looking to leverage strong typing alongside enhanced signal description capabilities. This integration promotes better development practices and reduces runtime errors, thanks to TypeScript's compile-time checks. Developers who use "human-signals" can therefore expect a seamless, error-reduced coding experience, making it an indispensable tool for modern backend applications that require robust process signal management. Whether you're a seasoned developer or just starting out, "human-signals" is designed to improve your productivity and elevate the quality of your Node.js applications.
Core dependencies of this npm package and its dev dependencies.
@ehmicky/dev-tasks, ajv, test-each
A README file for the human-signals code repository. View Code
Human-friendly process signals.
This is a map of known process signals with some information about each signal.
Unlike
os.constants.signals
this includes:
Please reach out if you're looking for a Node.js API or CLI engineer (11 years of experience). Most recently I have been Netlify Build's and Netlify Plugins' technical lead for 2.5 years. I am available for full-time remote positions.
import { signalsByName, signalsByNumber } from 'human-signals'
console.log(signalsByName.SIGINT)
// {
// name: 'SIGINT',
// number: 2,
// description: 'User interruption with CTRL-C',
// supported: true,
// action: 'terminate',
// forced: false,
// standard: 'ansi'
// }
console.log(signalsByNumber[8])
// {
// name: 'SIGFPE',
// number: 8,
// description: 'Floating point arithmetic error',
// supported: true,
// action: 'core',
// forced: false,
// standard: 'ansi'
// }
npm install human-signals
This package works in Node.js >=18.18.0.
This is an ES module. It must be loaded using
an import
or import()
statement,
not require()
. If TypeScript is used, it must be configured to
output ES modules,
not CommonJS.
Type: object
Object whose keys are signal names and values are signal objects.
Type: object
Object whose keys are signal numbers and values are signal objects.
Type: object
Signal object with the following properties.
Type: string
Standard name of the signal, for example 'SIGINT'
.
Type: number
Code number of the signal, for example 2
. While most number
are
cross-platform, some are different between different OS.
Type: string
Human-friendly description for the signal, for example
'User interruption with CTRL-C'
.
Type: boolean
Whether the current OS can handle this signal in Node.js using
process.on(name, handler)
.
The list of supported signals is OS-specific.
Type: string
Enum: 'terminate'
, 'core'
, 'ignore'
, 'pause'
, 'unpause'
What is the default action for this signal when it is not handled.
Type: boolean
Whether the signal's default action cannot be prevented. This is true
for
SIGTERM
, SIGKILL
and SIGSTOP
.
Type: string
Enum: 'ansi'
, 'posix'
, 'bsd'
, 'systemv'
, 'other'
Which standard defined that signal.
For any question, don't hesitate to submit an issue on GitHub.
Everyone is welcome regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.
This project was made with ❤️. The simplest way to give back is by starring and sharing it online.
If the documentation is unclear or has a typo, please click on the page's Edit
button (pencil icon) and suggest a correction.
If you would like to help us fix a bug or add a new feature, please check our guidelines. Pull requests are welcome!
Thanks go to our wonderful contributors:
ehmicky 💻 🎨 🤔 📖 |
electrovir 💻 |