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 7f989f0

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 6462b89 commit 7f989f0
Copy full SHA for 7f989f0

2 files changed

+8-6Lines changed: 8 additions & 6 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/child_process.md‎

Copy file name to clipboardExpand all lines: doc/api/child_process.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ or [`child_process.fork()`][].
24022402
[`subprocess.stdin`]: #subprocessstdin
24032403
[`subprocess.stdio`]: #subprocessstdio
24042404
[`subprocess.stdout`]: #subprocessstdout
2405-
[`util.convertProcessSignalToExitCode()`]: util.md#utilconvertprocesssignaltoexitcodesignalcode
2405+
[`util.convertProcessSignalToExitCode()`]: util.md#utilconvertprocesssignaltoexitcodesignal
24062406
[`util.promisify()`]: util.md#utilpromisifyoriginal
24072407
[synchronous counterparts]: #synchronous-process-creation
24082408
[v8.serdes]: v8.md#serialization-api
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: v24.14.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
@@ -3835,6 +3836,7 @@ npx codemod@latest @nodejs/util-is
38353836
[`mime.toString()`]: #mimetostring
38363837
[`mimeParams.entries()`]: #mimeparamsentries
38373838
[`napi_create_external()`]: n-api.md#napi_create_external
3839+
[`signal(7)`]: https://man7.org/linux/man-pages/man7/signal.7.html
38383840
[`target` and `handler`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#terminology
38393841
[`tty.hasColors()`]: tty.md#writestreamhascolorscount-env
38403842
[`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.