Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

processGroup.ts

12 lines429 Bytes

1/**
2 * `kill(0)` signals this server's own group and `kill(-1)` every process the
3 * user owns, and a fake spawner in tests reports pid 1.
4 */
5export function signalProcessGroup(pid: number, signal: NodeJS.Signals | 0): void {
6 if (!Number.isSafeInteger(pid) || pid <= 1) {
7 throw Object.assign(new Error(`kill ESRCH: not a spawned process group (${pid})`), {
8 code: "ESRCH",
9 });
10 }
11 process.kill(-pid, signal);