function killProcessGroup
killProcessGroup(pid: number): void

Sends SIGKILL to a process and its entire process group. Requires the target to have been spawned with detached: true so that PGID === pid.

On Windows, uses taskkill /F /T to kill the process and its entire child tree (renderer, GPU, crashpad helpers etc. that survive a plain process.kill() on Windows). Errors are silently suppressed — ESRCH means the process already exited, which is what we were asking for.

import type { ChildProcess } from 'node:child_process';

// Defined, not invoked: SIGKILLs a live process group.
function reapChrome(chrome: ChildProcess) {
  if (chrome.pid) killProcessGroup(chrome.pid); // takes renderer/GPU helpers down with it
}

Parameters

pid: number

Return Type

void

Usage

import { killProcessGroup } from "lib/utils/kill-process-group.ts";