diff --git a/lib/kill.js b/lib/kill.js index c23d6a5ad5..dc1c77c384 100644 --- a/lib/kill.js +++ b/lib/kill.js @@ -85,7 +85,7 @@ const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise // `cleanup` option handling const setExitHandler = (spawned, {cleanup, detached}, timedPromise) => { if (!cleanup || detached) { - return; + return timedPromise; } const removeExitHandler = onExit(() => { diff --git a/test/fixtures/sub-process-exit b/test/fixtures/sub-process-exit index 2b350a2b66..ea05f0e2d4 100755 --- a/test/fixtures/sub-process-exit +++ b/test/fixtures/sub-process-exit @@ -4,4 +4,14 @@ const execa = require('../..'); const cleanup = process.argv[2] === 'true'; const detached = process.argv[3] === 'true'; -execa('node', ['./test/fixtures/noop'], {cleanup, detached}); + +const runChild = async () => { + try { + await execa('node', ['./test/fixtures/noop'], {cleanup, detached}); + } catch (error) { + console.error(error); + process.exit(1); + } +}; + +runChild();