diff options
author | Robert Rossmann <rr.rossmann@me.com> | 2017-09-25 11:28:00 +0200 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-11-22 14:35:39 -0800 |
commit | 9b2cf1c8ebdf9483aaa1f0d1b6770043c229a354 (patch) | |
tree | 8da6c4a63f14a74cd6ad5ce95369a6fafd2fba94 /doc | |
parent | 13db29b2f7f0970c16228790f755262b3617f31e (diff) | |
download | android-node-v8-9b2cf1c8ebdf9483aaa1f0d1b6770043c229a354.tar.gz android-node-v8-9b2cf1c8ebdf9483aaa1f0d1b6770043c229a354.tar.bz2 android-node-v8-9b2cf1c8ebdf9483aaa1f0d1b6770043c229a354.zip |
process: Send signal name to signal handlers
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 178928c8b6..755dfb537c 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -350,6 +350,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). @@ -362,6 +365,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); ``` *Note*: An easy way to send the `SIGINT` signal is with `<Ctrl>-C` in most |