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!');
});

贡献者指南