(child: ChildProcess | null, timeoutMs: number)
| 4303 | } |
| 4304 | |
| 4305 | function waitForChildExit(child: ChildProcess | null, timeoutMs: number): Promise<void> { |
| 4306 | return new Promise<void>((resolve, reject) => { |
| 4307 | if (!child || child.exitCode !== null) { |
| 4308 | resolve(); |
| 4309 | return; |
| 4310 | } |
| 4311 | const timer = setTimeout(() => { |
| 4312 | cleanup(); |
| 4313 | reject(new Error('Timed out waiting for Codex child process to exit')); |
| 4314 | }, timeoutMs); |
| 4315 | const onExit = () => { |
| 4316 | cleanup(); |
| 4317 | resolve(); |
| 4318 | }; |
| 4319 | const cleanup = () => { |
| 4320 | clearTimeout(timer); |
| 4321 | child.off('exit', onExit); |
| 4322 | }; |
| 4323 | child.on('exit', onExit); |
| 4324 | }); |
| 4325 | } |
| 4326 | |
| 4327 | async function terminateChildProcess(child: ChildProcess, platform: NodeJS.Platform): Promise<void> { |
| 4328 | if (platform === 'win32' && typeof child.pid === 'number') { |
no test coverage detected