GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: correct `util.convertProcessSignalToExitCode` validation behavior · windwiny/node@84ae06e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • util.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/util.md‎

Copy file name to clipboardExpand all lines: doc/api/util.md
+7-5Lines changed: 7 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -89,35 +89,36 @@ callbackFunction((err, ret) => {
8989
});
9090
```
9191

92-
## `util.convertProcessSignalToExitCode(signalCode)`
92+
## `util.convertProcessSignalToExitCode(signal)`
9393

9494
<!-- YAML
9595
added:
9696
- v25.4.0
9797
- v24.14.0
9898
-->
9999

100-
* `signalCode` {string} A signal name (e.g., `'SIGTERM'`, `'SIGKILL'`).
101-
* Returns: {number|null} The exit code, or `null` if the signal is invalid.
100+
* `signal` {string} A signal name (e.g. `'SIGTERM'`)
101+
* Returns: {number} The exit code corresponding to `signal`
102102

103103
The `util.convertProcessSignalToExitCode()` method converts a signal name to its
104104
corresponding POSIX exit code. Following the POSIX standard, the exit code
105105
for a process terminated by a signal is calculated as `128 + signal number`.
106106

107+
If `signal` is not a valid signal name, then an error will be thrown. See
108+
[`signal(7)`][] for a list of valid signals.
109+
107110
```mjs
108111
import { convertProcessSignalToExitCode } from 'node:util';
109112

110113
console.log(convertProcessSignalToExitCode('SIGTERM')); // 143 (128 + 15)
111114
console.log(convertProcessSignalToExitCode('SIGKILL')); // 137 (128 + 9)
112-
console.log(convertProcessSignalToExitCode('INVALID')); // null
113115
```
114116

115117
```cjs
116118
const { convertProcessSignalToExitCode } = require('node:util');
117119

118120
console.log(convertProcessSignalToExitCode('SIGTERM')); // 143 (128 + 15)
119121
console.log(convertProcessSignalToExitCode('SIGKILL')); // 137 (128 + 9)
120-
console.log(convertProcessSignalToExitCode('INVALID')); // null
121122
```
122123

123124
This is particularly useful when working with processes to determine
@@ -3869,6 +3870,7 @@ npx codemod@latest @nodejs/util-is
38693870
[`mime.toString()`]: #mimetostring
38703871
[`mimeParams.entries()`]: #mimeparamsentries
38713872
[`napi_create_external()`]: n-api.md#napi_create_external
3873+
[`signal(7)`]: https://man7.org/linux/man-pages/man7/signal.7.html
38723874
[`target` and `handler`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#terminology
38733875
[`tty.hasColors()`]: tty.md#writestreamhascolorscount-env
38743876
[`util.diff()`]: #utildiffactual-expected

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.