| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
@alloc/tree-kill kills a spawned process and its descendants across macOS, Linux, and Windows.
It is a rewrite of the original tree-kill package that preserves the same OS-specific traversal strategy but changes the public API to a ProcessLike interface with separate async and sync entrypoints instead of a raw pid plus callback.
pnpm add @alloc/tree-killimport { spawn } from "node:child_process";
import treeKill from "@alloc/tree-kill";
const child = spawn(process.execPath, ["-e", "setInterval(() => {}, 1000)"], {
stdio: "ignore",
});
await treeKill(child, "SIGTERM");Use the synchronous export only in shutdown paths where async work cannot be awaited reliably, such as process.on("exit"):
import { spawn } from "node:child_process";
import treeKill, { treeKillSync } from "@alloc/tree-kill";
const child = spawn(process.execPath, ["-e", "setInterval(() => {}, 1000)"], {
stdio: "ignore",
});
await treeKill(child, "SIGTERM");
process.on("exit", () => {
treeKillSync(child, "SIGTERM");
});| Back | FazBrowse Home | New Git URL |