From 25ad8decc6c15e45659053605af4f7b53dd64e1b 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 b8e518f6a1d..148dfdc0f7f 100644 --- a/lib/internal/process/main_thread_only.js +++ b/lib/internal/process/main_thread_only.js @@ -154,6 +154,13 @@ function setupSignalHandlers(internalBinding) { 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() {