diff options
author | Robert Rossmann <rr.rossmann@me.com> | 2017-09-25 12:28:00 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-09-06 19:40:48 +0300 |
commit | 711098e88cef3ec0cbfaf9b0cd8ecac73f30425f (patch) | |
tree | 06080e0cc3ce5a3ecb23bc83d37134d2267d320f /doc | |
parent | ec1828c2b67a84d5a6ca54fb34138510b3cfb135 (diff) |
process: Send signal name to signal handlers
Backport-PR-URL: https://github.com/nodejs/node/pull/22380
PR-URL: https://github.com/nodejs/node/pull/15606
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/process.md | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/api/process.md b/doc/api/process.md index 574fc933671..74d9fb0cc15 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -349,6 +349,9 @@ Signal events will be emitted when the Node.js process receives a signal. Please refer to signal(7) for a listing of standard POSIX signal names such as `SIGINT`, `SIGHUP`, etc. +The signal handler will receive the signal's name (`'SIGINT'`, + `'SIGTERM'`, etc.) as the first argument. + The name of each event will be the uppercase common name for the signal (e.g. `'SIGINT'` for `SIGINT` signals). @@ -361,6 +364,14 @@ process.stdin.resume(); process.on('SIGINT', () => { console.log('Received SIGINT. Press Control-D to exit.'); }); + +// Using a single function to handle multiple signals +function handle(signal) { + console.log(`Received ${signal}`); +} + +process.on('SIGINT', handle); +process.on('SIGTERM', handle); ``` * `SIGUSR1` is reserved by Node.js to start the [debugger][]. It's possible to |