forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process: Send signal name to signal handlers
PR-URL: nodejs#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>
- Loading branch information
1 parent
60c81c0
commit f56a4ba
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
if (common.isWindows) { | ||
common.skip('Sending signals with process.kill is not supported on Windows'); | ||
} | ||
|
||
process.once('SIGINT', common.mustCall((signal) => { | ||
assert.strictEqual(signal, 'SIGINT'); | ||
})); | ||
|
||
process.kill(process.pid, 'SIGINT'); | ||
|
||
process.once('SIGTERM', common.mustCall((signal) => { | ||
assert.strictEqual(signal, 'SIGTERM'); | ||
})); | ||
|
||
process.kill(process.pid, 'SIGTERM'); | ||
|
||
// Prevent Node.js from exiting due to empty event loop before signal handlers | ||
// are fired | ||
setImmediate(() => {}); |