Skip to content

Repository files navigation

@alloc/tree-kill

Purpose

@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.

Installation

pnpm add @alloc/tree-kill

Quick Example

import{spawn}from"node:child_process";importtreeKillfrom"@alloc/tree-kill";constchild=spawn(process.execPath,["-e","setInterval(() => {}, 1000)"],{stdio: "ignore",});awaittreeKill(child,"SIGTERM");

Exit-Time Fallback

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";importtreeKill,{treeKillSync}from"@alloc/tree-kill";constchild=spawn(process.execPath,["-e","setInterval(() => {}, 1000)"],{stdio: "ignore",});awaittreeKill(child,"SIGTERM");process.on("exit",()=>{treeKillSync(child,"SIGTERM");});

Documentation Map

  • Conceptual behavior, platform notes, and rewrite boundaries: docs/context.md
  • Runnable repository example: examples/basic-usage.ts
  • Exact exported signatures: run pnpm build and inspect dist/index.d.mts

About

Fork of node-tree-kill

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages