MCPcopy Create free account
hub / github.com/vercel/vercel / nukePID

Function nukePID

packages/cli/test/dev/utils.ts:732–764  ·  view source on GitHub ↗
(
  pid: number,
  signal: string = 'SIGTERM',
  retries: number = 10
)

Source from the content-addressed store, hash-verified

730}
731
732async function nukePID(
733 pid: number,
734 signal: string = 'SIGTERM',
735 retries: number = 10
736) {
737 if (retries === 0) {
738 console.log(`pid ${pid} won't die, giving up`);
739 return;
740 }
741
742 // kill the process
743 try {
744 process.kill(pid, signal);
745 } catch (_e) {
746 // process does not exist
747
748 console.log(`pid ${pid} is not running`);
749 return;
750 }
751
752 await sleep(250);
753
754 try {
755 // check if killed
756 process.kill(pid, 0);
757 } catch (_e) {
758 console.log(`pid ${pid} is not running`);
759 return;
760 }
761
762 console.log(`pid ${pid} didn't exit, sending SIGKILL (retries ${retries})`);
763 await nukePID(pid, 'SIGKILL', retries - 1);
764}
765
766export async function nukeProcessTree(pid: number, signal?: string) {
767 if (process.platform === 'win32') {

Callers 1

nukeProcessTreeFunction · 0.85

Calls 3

killMethod · 0.80
sleepFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected