Files
mcp_web_dev_server/node_modules/execa/lib/terminate/cleanup.js
T
2026-07-31 13:12:54 -04:00

17 lines
411 B
JavaScript

import {addAbortListener} from 'node:events';
import {onExit} from 'signal-exit';
// If the `cleanup` option is used, call `subprocess.kill()` when the parent process exits
export const cleanupOnExit = (kill, {cleanup, detached}, {signal}) => {
if (!cleanup || detached) {
return;
}
const removeExitHandler = onExit(() => {
kill();
});
addAbortListener(signal, () => {
removeExitHandler();
});
};