MCPcopy Create free account
hub / github.com/anomalyco/opencode / stopWorker

Function stopWorker

packages/core/test/util/effect-flock.test.ts:69–88  ·  view source on GitHub ↗
(proc: ReturnType<typeof spawnWorker>)

Source from the content-addressed store, hash-verified

67}
68
69async function stopWorker(proc: ReturnType<typeof spawnWorker>) {
70 if (proc.exitCode !== null || proc.signalCode !== null) return
71
72 const closed = new Promise<void>((resolve) => proc.once("close", () => resolve()))
73
74 if (process.platform !== "win32" || !proc.pid) {
75 proc.kill()
76 await closed
77 return
78 }
79
80 await new Promise<void>((resolve) => {
81 const killProc = spawn("taskkill", ["/pid", String(proc.pid), "/T", "/F"])
82 killProc.on("close", () => {
83 proc.kill()
84 resolve()
85 })
86 })
87 await closed
88}
89
90async function waitForFile(file: string, timeout = 3_000) {
91 const stop = Date.now() + timeout

Callers 1

Calls 3

onMethod · 0.80
resolveFunction · 0.50
spawnFunction · 0.50

Tested by

no test coverage detected