包详细信息

human-signals

ehmicky286.9mApache-2.08.0.1

Human-friendly process signals

signal, signals, handlers, error-handling

自述文件

Node TypeScript Codecov Mastodon Medium

Human-friendly process signals.

This is a map of known process signals with some information about each signal.

Unlike os.constants.signals this includes:

Example

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'
// }

Install

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.

Usage

signalsByName

Type: object

Object whose keys are signal names and values are signal objects.

signalsByNumber

Type: object

Object whose keys are signal numbers and values are signal objects.

signal

Type: object

Signal object with the following properties.

name

Type: string

Standard name of the signal, for example 'SIGINT'.

number

Type: number

Code number of the signal, for example 2. While most number are cross-platform, some are different between different OS.

description

Type: string

Human-friendly description for the signal, for example 'User interruption with CTRL-C'.

supported

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.

action

Type: string\ Enum: 'terminate', 'core', 'ignore', 'pause', 'unpause'

What is the default action for this signal when it is not handled.

forced

Type: boolean

Whether the signal's default action cannot be prevented. This is true for SIGTERM, SIGKILL and SIGSTOP.

standard

Type: string\ Enum: 'ansi', 'posix', 'bsd', 'systemv', 'other'

Which standard defined that signal.

Support

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.

Contributing

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
ehmicky

💻 🎨 🤔 📖
electrovir
electrovir

💻
Felix Zedén Yverås
Felix Zedén Yverås

💻 ⚠️

更新日志

8.0.1

Documentation

  • Improve documentation in README.md

8.0.0

Breaking changes (types)

  • The SignalNumber and Signal['number'] types in TypeScript are now stricter. They only allow valid signal numbers like 1 or 9. They do not allow invalid signal numbers like -1, 1.5 or 999. Please note that 0 is not considered a valid signal number, although it can be passed to process.kill().

Types

  • The signalsByName[signalName] and signalsByNumber[signalNumber] types in TypeScript are now Signal instead of Signal | undefined. This means you can now do signalsByName[signalName].description instead of signalsByName[signalName]!.description.

7.0.0

Breaking changes (types)

  • The SignalName and Signal['name'] types in TypeScript are now stricter. They only allow valid signal names like 'SIGINT'. They do not allow lowercase signals like 'sigint' nor unknown signals like 'SIGOTHER'.

6.0.0

Breaking changes

  • Minimal supported Node.js version is now 18.18.0

5.0.0

Breaking changes

  • Minimal supported Node.js version is now 16.17.0

4.3.1

Bug fixes

4.3.0

Features

  • Improve tree-shaking support

4.2.0

Features

  • Reduce npm package size

4.1.0

Features

  • Improve TypeScript types

4.0.0

Breaking changes

  • Minimal supported Node.js version is now 14.18.0

3.0.1

Bug fixes

  • Fix main field in package.json

3.0.0

Breaking changes

  • Minimal supported Node.js version is now 12.20.0
  • This package is now an ES module. It can only be loaded with an import or import() statement, not require(). See this post for more information.

2.1.0

TypeScript types

2.0.0

Breaking changes

  • Minimal supported Node.js version is now 10.17.0