From 54d847dca51d72e8dcad621d1634754c4a5abc8c Mon Sep 17 00:00:00 2001 From: Gireesh Punathil Date: Mon, 26 Nov 2018 01:38:47 -0500 Subject: [PATCH] lib: rearm pre-existing signal event registrations process.on('somesignal', ...) semantics expect the process to catch the signal and invoke the associated handler. `setupSignalHandlers` perform the additional task of preparing the libuv signal handler and associate it with the event handler. It is possible that by the time this is setup there could be pre-existing registrations that pre-date this setup in the boot sequence. So rearm pre-existing signal event registrations to get upto speed. Ref: https://github.com/nodejs/node/pull/22712#discussion_r232457318 PR-URL: https://github.com/nodejs/node/pull/24651 Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson Reviewed-By: Franziska Hinkelmann Reviewed-By: Joyee Cheung --- lib/internal/process/main_thread_only.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/internal/process/main_thread_only.js b/lib/internal/process/main_thread_only.js index 814cca266d6675..6fb238df72e5c1 100644 --- a/lib/internal/process/main_thread_only.js +++ b/lib/internal/process/main_thread_only.js @@ -102,6 +102,13 @@ function setupSignalHandlers() { delete signalWraps[type]; } }); + + // re-arm pre-existing signal event registrations + // with this signal wrap capabilities. + process.eventNames().forEach((ev) => { + if (isSignal(ev)) + process.emit('newListener', ev); + }); } function setupChildProcessIpcChannel() {