( child: ChildProcess, options: Pick<ExecOptions, 'detached' | 'signal'>, )
| 700 | } |
| 701 | |
| 702 | function watchCommandAbort( |
| 703 | child: ChildProcess, |
| 704 | options: Pick<ExecOptions, 'detached' | 'signal'>, |
| 705 | ): { readonly didAbort: boolean; dispose: () => void } { |
| 706 | let didAbort = false; |
| 707 | const onAbort = () => { |
| 708 | didAbort = true; |
| 709 | killProcessTree(child, options.detached); |
| 710 | }; |
| 711 | if (options.signal?.aborted) { |
| 712 | onAbort(); |
| 713 | } else { |
| 714 | options.signal?.addEventListener('abort', onAbort, { once: true }); |
| 715 | } |
| 716 | return { |
| 717 | get didAbort() { |
| 718 | return didAbort; |
| 719 | }, |
| 720 | dispose: () => { |
| 721 | options.signal?.removeEventListener('abort', onAbort); |
| 722 | }, |
| 723 | }; |
| 724 | } |
| 725 | |
| 726 | function killProcessTree(child: ChildProcess, detached: boolean | undefined): void { |
| 727 | if (detached && child.pid && process.platform !== 'win32') { |
no test coverage detected