-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: #15606 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Bartosz Sosnowski <[email protected]>
- Loading branch information
1 parent
13db29b
commit 9b2cf1c
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(() => {}); |