(pid: number)
| 31 | }; |
| 32 | |
| 33 | export const killtree = async (pid: number) => { |
| 34 | let descendants = await pidtree(pid); |
| 35 | let pids = [pid, ...descendants]; |
| 36 | |
| 37 | await Promise.all(pids.map(kill)); |
| 38 | |
| 39 | return new Promise<void>((resolve, reject) => { |
| 40 | let check = setInterval(() => { |
| 41 | pids = pids.filter(isAlive); |
| 42 | if (pids.length === 0) { |
| 43 | clearInterval(check); |
| 44 | resolve(); |
| 45 | } |
| 46 | }, 50); |
| 47 | |
| 48 | setTimeout(() => { |
| 49 | clearInterval(check); |
| 50 | reject(new Error("Timeout: Processes did not exit within the specified time.")); |
| 51 | }, 2000); |
| 52 | }); |
| 53 | }; |
no outgoing calls
no test coverage detected