diff --git a/test.js b/test.js index fb5dbc02e7..e44b90f40f 100644 --- a/test.js +++ b/test.js @@ -507,3 +507,20 @@ test('detach child process', async t => { t.is(fs.readFileSync(file, 'utf8'), 'foo\n'); }); + +// https://github.com/sindresorhus/execa/issues/128 +test('removes exit handler on exit', async t => { + // TODO this relies on signal-exit internals + const ee = process.__signal_exit_emitter__; + + const child = m('noop'); + const listener = ee.listeners('exit').pop(); + + await new Promise((resolve, reject) => { + child.on('error', reject); + child.on('exit', resolve); + }); + + const included = ee.listeners('exit').includes(listener); + t.false(included); +});