sindresorhus/execa

Ability to kill all descendents of the child process

已關閉

#96 建立於 2017年6月23日

 (14 則留言) (13 個反應) (0 位負責人)JavaScript (219 個分叉)batch import
enhancementhelp wanted

倉庫指標

星標
 (6,091 顆星)
PR 合併指標
 (平均合併 6天 18小時) (30 天內合併 6 個 PR)

描述

When I'm working with child processes, I sometimes end up with detached processes running indefinitely after I've killed the direct child, which can lead to blocked ports and memory leaks.

I sometimes fix this by using a module like ps-tree to find out all the descendants PIDs, and then send all of them a kill command, but it feels messy. It would be nice if execa could provide a clean, cross-platform API for this.

Maybe something like this:

const execa = require('execa');

const child = execa('./something');

// ...

child.killTree().then(() => {
  console.log('all dead!');
});

貢獻者指南