MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / deadPid

Function deadPid

__tests__/daemon-registry.test.ts:16–22  ·  view source on GitHub ↗

A pid that's guaranteed dead: spawn a trivial process, let it exit, reap it.

()

Source from the content-addressed store, hash-verified

14
15/** A pid that's guaranteed dead: spawn a trivial process, let it exit, reap it. */
16async function deadPid(): Promise<number> {
17 const child = spawn(process.execPath, ['-e', 'process.exit(0)']);
18 const pid = child.pid!;
19 await new Promise<void>((r) => child.on('exit', () => r()));
20 await new Promise((r) => setTimeout(r, 50)); // let the OS reap it
21 return pid;
22}
23
24function rec(root: string, pid: number, startedAt = Date.now()): DaemonRecord {
25 return { root, pid, version: '1.0.0', socketPath: `${root}/.codegraph/daemon.sock`, startedAt };

Callers 1

Calls 1

onMethod · 0.65

Tested by

no test coverage detected