MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / fetchProcessInfo

Function fetchProcessInfo

src/utils/process-tree.ts:39–70  ·  view source on GitHub ↗
(pid: string)

Source from the content-addressed store, hash-verified

37 };
38
39 const fetchProcessInfo = async (pid: string): Promise<ProcessTreeEntry | null> => {
40 const command = ['-o', 'pid=,ppid=,comm=,args=', '-p', pid];
41 const attempts = [
42 { bin: '/bin/ps', label: 'Get process info (ps)' },
43 { bin: 'ps', label: 'Get process info (ps fallback)' },
44 ];
45
46 for (const attempt of attempts) {
47 try {
48 const res = await executor([attempt.bin, ...command], attempt.label);
49 if (!res.success) {
50 lastError = res.error ?? `ps returned non-zero exit code for pid ${pid}`;
51 continue;
52 }
53 const line = res.output.trim().split('\n')[0]?.trim();
54 if (!line) {
55 lastError = `ps returned no output for pid ${pid}`;
56 continue;
57 }
58 const parsed = parseLine(line);
59 if (!parsed) {
60 lastError = `ps output was not parseable for pid ${pid}`;
61 continue;
62 }
63 return parsed;
64 } catch (error) {
65 lastError = error instanceof Error ? error.message : String(error);
66 }
67 }
68
69 return null;
70 };
71
72 while (currentPid && currentPid !== '0' && !seen.has(currentPid)) {
73 seen.add(currentPid);

Callers 1

getProcessTreeFunction · 0.85

Calls 2

parseLineFunction · 0.85
executorFunction · 0.50

Tested by

no test coverage detected