Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 83719ff

Browse filesBrowse files
Renegade334aduh95
authored andcommitted
doc: correct util.convertProcessSignalToExitCode validation behavior
PR-URL: #62134 Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 5439d0e commit 83719ff
Copy full SHA for 83719ff

1 file changed

+7-5Lines changed: 7 additions & 5 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
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,33 +89,34 @@ callbackFunction((err, ret) => {
8989
});
9090
```
9191

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

9494
<!-- YAML
9595
added: v25.4.0
9696
-->
9797

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

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

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

108111
console.log(convertProcessSignalToExitCode('SIGTERM')); // 143 (128 + 15)
109112
console.log(convertProcessSignalToExitCode('SIGKILL')); // 137 (128 + 9)
110-
console.log(convertProcessSignalToExitCode('INVALID')); // null
111113
```
112114

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

116118
console.log(convertProcessSignalToExitCode('SIGTERM')); // 143 (128 + 15)
117119
console.log(convertProcessSignalToExitCode('SIGKILL')); // 137 (128 + 9)
118-
console.log(convertProcessSignalToExitCode('INVALID')); // null
119120
```
120121

121122
This is particularly useful when working with processes to determine
@@ -3864,6 +3865,7 @@ npx codemod@latest @nodejs/util-is
38643865
[`mime.toString()`]: #mimetostring
38653866
[`mimeParams.entries()`]: #mimeparamsentries
38663867
[`napi_create_external()`]: n-api.md#napi_create_external
3868+
[`signal(7)`]: https://man7.org/linux/man-pages/man7/signal.7.html
38673869
[`target` and `handler`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#terminology
38683870
[`tty.hasColors()`]: tty.md#writestreamhascolorscount-env
38693871
[`util.diff()`]: #utildiffactual-expected

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.