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

Function ps

packages/cli/test/dev/utils.ts:705–730  ·  view source on GitHub ↗
(parentPid: number, pids: Record<string, Array<number>> = {})

Source from the content-addressed store, hash-verified

703}
704
705async function ps(parentPid: number, pids: Record<string, Array<number>> = {}) {
706 const cmd: string[] =
707 process.platform === 'darwin'
708 ? ['pgrep', '-P', parentPid.toString()]
709 : ['ps', '-o', 'pid', '--no-headers', '--ppid', parentPid.toString()];
710
711 try {
712 const buf = execFileSync(cmd[0], cmd.slice(1), {
713 encoding: 'utf-8',
714 });
715 const possiblePids = buf.match(/\d+/g) || [];
716 for (const rawPid of possiblePids) {
717 const pid = parseInt(rawPid);
718 const recurse = Object.prototype.hasOwnProperty.call(pids, pid);
719 pids[parentPid].push(pid);
720 pids[pid] = [];
721 if (recurse) {
722 await ps(pid, pids);
723 }
724 }
725 } catch (err) {
726 const error = err as Error;
727 console.log(`Failed to get processes: ${error.toString()}`);
728 }
729 return pids;
730}
731
732async function nukePID(
733 pid: number,

Callers 2

testFixtureFunction · 0.85
nukeProcessTreeFunction · 0.85

Calls 4

pushMethod · 0.65
toStringMethod · 0.45
matchMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected