From bd3242b47f6c6ce86ea2f8fae1e39079e2aca3e9 Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Tue, 23 Jan 2018 17:33:16 -0500 Subject: [PATCH 1/2] process: remove dead code --- lib/internal/process.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/internal/process.js b/lib/internal/process.js index e58b83d21631ff..71db75b91685ea 100644 --- a/lib/internal/process.js +++ b/lib/internal/process.js @@ -227,14 +227,7 @@ function setupChannel() { // Make sure it's not accidentally inherited by child processes. delete process.env.NODE_CHANNEL_FD; - const cp = require('child_process'); - - // Load tcp_wrap to avoid situation where we might immediately receive - // a message. - // FIXME is this really necessary? - process.binding('tcp_wrap'); - - cp._forkChild(fd); + require('child_process')._forkChild(fd); assert(process.send); } } From 9382a5569e1d154bf83ba5e2a7f051c70be8327d Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Tue, 23 Jan 2018 18:18:04 -0500 Subject: [PATCH 2/2] process: clean up signal handler setup --- lib/internal/process.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/internal/process.js b/lib/internal/process.js index 71db75b91685ea..757c8de8e685f1 100644 --- a/lib/internal/process.js +++ b/lib/internal/process.js @@ -178,24 +178,23 @@ function setupKillAndExit() { function setupSignalHandlers() { - // Load events module in order to access prototype elements on process like - // process.addListener. - const signalWraps = {}; + const signalWraps = Object.create(null); + let Signal; function isSignal(event) { return typeof event === 'string' && constants[event] !== undefined; } // Detect presence of a listener for the special signal types - process.on('newListener', function(type, listener) { - if (isSignal(type) && - !signalWraps.hasOwnProperty(type)) { - const Signal = process.binding('signal_wrap').Signal; + process.on('newListener', function(type) { + if (isSignal(type) && signalWraps[type] === undefined) { + if (Signal === undefined) + Signal = process.binding('signal_wrap').Signal; const wrap = new Signal(); wrap.unref(); - wrap.onsignal = function() { process.emit(type, type); }; + wrap.onsignal = process.emit.bind(process, type, type); const signum = constants[type]; const err = wrap.start(signum); @@ -208,8 +207,8 @@ function setupSignalHandlers() { } }); - process.on('removeListener', function(type, listener) { - if (signalWraps.hasOwnProperty(type) && this.listenerCount(type) === 0) { + process.on('removeListener', function(type) { + if (signalWraps[type] !== undefined && this.listenerCount(type) === 0) { signalWraps[type].close(); delete signalWraps[type]; }