MCPcopy Create free account
hub / github.com/apache/maka / waitForProcessExit

Function waitForProcessExit

packages/runtime/src/__tests__/shell-exec.test.ts:28–40  ·  view source on GitHub ↗
(pid: number, timeoutMs = 3_000)

Source from the content-addressed store, hash-verified

26}
27
28async function waitForProcessExit(pid: number, timeoutMs = 3_000): Promise<void> {
29 const deadline = Date.now() + timeoutMs;
30 while (true) {
31 try {
32 process.kill(pid, 0);
33 } catch (error) {
34 if ((error as NodeJS.ErrnoException).code === 'ESRCH') return;
35 throw error;
36 }
37 if (Date.now() >= deadline) throw new Error(`Detached descendant ${pid} is still running`);
38 await delay(20);
39 }
40}
41
42function findPwsh(): string | undefined {
43 const exeNames = process.platform === 'win32' ? ['pwsh.exe'] : ['pwsh', 'pwsh-preview'];

Callers 1

shell-exec.test.tsFile · 0.70

Calls 3

delayFunction · 0.70
nowMethod · 0.65
killMethod · 0.65

Tested by

no test coverage detected