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

processGroup.ts

9 lines380 Bytes

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