diff --git a/test/async-hooks/test-signalwrap.js b/test/async-hooks/test-signalwrap.js index fa975ff0178f3c..ae4f41c6a413ba 100644 --- a/test/async-hooks/test-signalwrap.js +++ b/test/async-hooks/test-signalwrap.js @@ -1,7 +1,8 @@ 'use strict'; const common = require('../common'); -if (common.isWindows) return common.skip('no signals in Windows'); +if (common.isWindows) + common.skip('no signals in Windows'); const assert = require('assert'); const initHooks = require('./init-hooks'); @@ -11,6 +12,10 @@ const exec = require('child_process').exec; const hooks = initHooks(); hooks.enable(); + +// Keep the event loop open so process doesn't exit before receiving signals. +const interval = setInterval(() => {}, 9999); + process.on('SIGUSR2', common.mustCall(onsigusr2, 2)); const as = hooks.activitiesOfTypes('SIGNALWRAP'); @@ -66,6 +71,7 @@ function onsigusr2() { } function onsigusr2Again() { + clearInterval(interval); setImmediate(() => { checkInvocations( signal1, { init: 1, before: 2, after: 2, destroy: 1 },