| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,33 +89,34 @@ callbackFunction((err, ret) => { | |||
| 89 | 89 | }); | |
| 90 | 90 | ``` | |
| 91 | 91 | ||
| 92 | - ## `util.convertProcessSignalToExitCode(signalCode)` | ||
| 92 | + ## `util.convertProcessSignalToExitCode(signal)` | ||
| 93 | 93 | ||
| 94 | 94 | <!-- YAML | |
| 95 | 95 | added: v25.4.0 | |
| 96 | 96 | --> | |
| 97 | 97 | ||
| 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` | ||
| 100 | 100 | ||
| 101 | 101 | The `util.convertProcessSignalToExitCode()` method converts a signal name to its | |
| 102 | 102 | corresponding POSIX exit code. Following the POSIX standard, the exit code | |
| 103 | 103 | for a process terminated by a signal is calculated as `128 + signal number`. | |
| 104 | 104 | ||
| 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 | + | ||
| 105 | 108 | ```mjs | |
| 106 | 109 | import { convertProcessSignalToExitCode } from 'node:util'; | |
| 107 | 110 | ||
| 108 | 111 | console.log(convertProcessSignalToExitCode('SIGTERM')); // 143 (128 + 15) | |
| 109 | 112 | console.log(convertProcessSignalToExitCode('SIGKILL')); // 137 (128 + 9) | |
| 110 | - console.log(convertProcessSignalToExitCode('INVALID')); // null | ||
| 111 | 113 | ``` | |
| 112 | 114 | ||
| 113 | 115 | ```cjs | |
| 114 | 116 | const { convertProcessSignalToExitCode } = require('node:util'); | |
| 115 | 117 | ||
| 116 | 118 | console.log(convertProcessSignalToExitCode('SIGTERM')); // 143 (128 + 15) | |
| 117 | 119 | console.log(convertProcessSignalToExitCode('SIGKILL')); // 137 (128 + 9) | |
| 118 | - console.log(convertProcessSignalToExitCode('INVALID')); // null | ||
| 119 | 120 | ``` | |
| 120 | 121 | ||
| 121 | 122 | This is particularly useful when working with processes to determine | |
@@ -3864,6 +3865,7 @@ npx codemod@latest @nodejs/util-is | |||
| 3864 | 3865 | [`mime.toString()`]: #mimetostring | |
| 3865 | 3866 | [`mimeParams.entries()`]: #mimeparamsentries | |
| 3866 | 3867 | [`napi_create_external()`]: n-api.md#napi_create_external | |
| 3868 | + [`signal(7)`]: https://man7.org/linux/man-pages/man7/signal.7.html | ||
| 3867 | 3869 | [`target` and `handler`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#terminology | |
| 3868 | 3870 | [`tty.hasColors()`]: tty.md#writestreamhascolorscount-env | |
| 3869 | 3871 | [`util.diff()`]: #utildiffactual-expected | |
| Back | FazBrowse Home | New Git URL |
0 commit comments