(proc: ChildProcess)
| 149 | * them (and their sign-in windows) behind. |
| 150 | */ |
| 151 | const killProcessTree = (proc: ChildProcess) => { |
| 152 | const { pid } = proc; |
| 153 | if (!pid) { |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | if (process.platform === 'win32') { |
| 158 | spawn('taskkill', ['/pid', String(pid), '/T', '/F'], { stdio: 'ignore', windowsHide: true }).on('error', err => { |
| 159 | console.warn('[NativeProvider] Failed to stop git credential process:', err.message); |
| 160 | }); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | // POSIX: the process was spawned detached, i.e. as the leader of its own process group. |
| 165 | const killGroup = (signal: NodeJS.Signals) => { |
| 166 | try { |
| 167 | process.kill(-pid, signal); |
| 168 | } catch { |
| 169 | // The group is already gone. |
| 170 | } |
| 171 | }; |
| 172 | killGroup('SIGTERM'); |
| 173 | setTimeout(() => killGroup('SIGKILL'), KILL_GRACE_MS).unref?.(); |
| 174 | }; |
| 175 | |
| 176 | /** |
| 177 | * Run `git credential <action>` with the given attributes on stdin. The result |
no test coverage detected