cleanup.js
This file
Path
lib/exit/cleanup.js
16 lines · 366 bytes · JavaScript
Last changed by
Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
History of this fileTake it
1234567891011121314151617import {addAbortListener} from 'node:events';import {onExit} from 'signal-exit';
// `cleanup` option handlingexport const cleanupOnExit = (subprocess, {cleanup, detached}, {signal}) => { if (!cleanup || detached) { return; }
const removeExitHandler = onExit(() => { subprocess.kill(); }); addAbortListener(signal, () => { removeExitHandler(); });};