Skip to content
Myr

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 file

Take it

Split files (#837)ehmickybefore adoption672c2d7

lines 1–4why, one step back
1import {addAbortListener} from 'node:events';
2import {onExit} from 'signal-exit';34// `cleanup` option handling

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 5why, one step back
5export const cleanupOnExit = (subprocess, {cleanup, detached}, {signal}) => {

Split files (#837)ehmickybefore adoption672c2d7

lines 6–10why, one step back
6 if (!cleanup || detached) {
7 return;8 }910 const removeExitHandler = onExit(() => {

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 11why, one step back
11 subprocess.kill();

Split files (#837)ehmickybefore adoption672c2d7

lines 12–16why, one step back
12 });
13 addAbortListener(signal, () => {14 removeExitHandler();15 });16};