child_process: add cross-platform subprocess.killTree([signal])
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
What is the problem this feature will solve?
subprocess.kill([signal]) only targets the direct child PID. Descendants often keep running, especially when:
shell: true(shell exits, real command survives)- the child is a build driver (
bash/make/ninja) that spawns grandchildren - on Windows, where POSIX signals are not real and
kill()does not terminate a process tree
Userland workarounds are fragmented and OS-specific:
- Unix:
detached: true+process.kill(-pid, signal)(process group; not always applicable) - Windows:
taskkill /pid <pid> /T /F(or equivalent) - npm packages such as
tree-kill
This comes up often for Ctrl+C / timeout cleanup in CLIs and build orchestrators.
Related prior request (closed stale): https://github.com/nodejs/node/issues/40438 (killDeep).
What is the feature you are proposing to solve the problem?
Add an explicit, documented API, for example:
subprocess.killTree([signal]);
// and/or
child_process.killTree(pid[, signal]);
Goals:
- Cross-platform: one call that best-effort terminates the process and its descendants on Windows, Linux, and macOS.
- Clear semantics vs
kill():kill()stays single-PID;killTree()is the tree variant. - Document limitations: PID reuse races, process-group vs true tree walk, signal mapping on Windows (where signals are not POSIX).
A reasonable Windows implementation can use the platform tree-terminate facility (today: taskkill /T); Unix can use process-group kill when the child is a group leader, otherwise a documented tree walk.
What alternatives have you considered?
- Keep using
tree-kill/ ad-hoctaskkillin every project - Rely on
detached+ negative PID (Unix-only, requires spawn options up front) - Expand
subprocess.kill()to kill trees (breaking / surprising; prefer a separatekillTreename)
Naming killTree (rather than overloading kill) makes the stronger, OS-dependent behavior opt-in and discoverable.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der child_process subprocess.kill API und vergleichen Sie den Unix-Prozessgruppenansatz mit Windows taskkill /T /F, der im Issue beschrieben wird. Definieren Sie die plattformübergreifende killTree-Semantik, die Signalzuordnung und die dokumentierten Einschränkungen, und überprüfen Sie anschließend das Verhalten unter Windows, Linux und macOS.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- api, operating-systems
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Aktiv
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 38/100