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

Function startDetachedProcess

__tests__/daemon-older-version.test.ts:149–159  ·  view source on GitHub ↗

A live process to stand in for a daemon; signals reach it, never the test.

()

Source from the content-addressed store, hash-verified

147
148/** A live process to stand in for a daemon; signals reach it, never the test. */
149function startDetachedProcess(): number {
150 const source = [
151 "const { spawn } = require('child_process');",
152 "const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { detached: true, stdio: 'ignore' });",
153 'child.unref();',
154 'console.log(child.pid);',
155 ].join(' ');
156 const pid = Number(execFileSync(process.execPath, ['-e', source], { encoding: 'utf8' }).trim());
157 if (!Number.isInteger(pid) || pid <= 0) throw new Error('could not start daemon fixture');
158 return pid;
159}
160
161async function deadPid(): Promise<number> {
162 const child = spawn(process.execPath, ['-e', 'process.exit(0)']);

Callers 2

fakeDaemonFunction · 0.70

Calls 2

NumberInterface · 0.85
joinMethod · 0.45

Tested by

no test coverage detected