(child: ChildProcessWithoutNullStreams, signal: NodeJS.Signals)
| 208 | } |
| 209 | |
| 210 | function tryKillProcess(child: ChildProcessWithoutNullStreams, signal: NodeJS.Signals): void { |
| 211 | if (process.platform === 'win32') { |
| 212 | // On Windows, `ChildProcess.kill()` only signals the shell spawned by |
| 213 | // `shell: true`, leaving grandchildren (the actual hook command) alive |
| 214 | // and holding the cwd. `taskkill /T` terminates the whole process tree. |
| 215 | killProcessTreeWindows(child, signal === 'SIGKILL'); |
| 216 | return; |
| 217 | } |
| 218 | try { |
| 219 | if (child.pid !== undefined) { |
| 220 | process.kill(-child.pid, signal); |
| 221 | } else { |
| 222 | child.kill(signal); |
| 223 | } |
| 224 | } catch { |
| 225 | try { |
| 226 | child.kill(signal); |
| 227 | } catch {} |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | function killProcessTreeWindows(child: ChildProcessWithoutNullStreams, force: boolean): void { |
| 232 | if (child.pid === undefined) return; |
no test coverage detected