( process: ChildProcessWithoutNullStreams, timeoutMs: number, )
| 383 | } |
| 384 | |
| 385 | async function waitForProcessExit( |
| 386 | process: ChildProcessWithoutNullStreams, |
| 387 | timeoutMs: number, |
| 388 | ): Promise<boolean> { |
| 389 | if (process.exitCode !== null) { |
| 390 | return true |
| 391 | } |
| 392 | |
| 393 | return await new Promise<boolean>(resolve => { |
| 394 | const timeout = setTimeout(() => { |
| 395 | cleanup() |
| 396 | resolve(false) |
| 397 | }, timeoutMs) |
| 398 | |
| 399 | const onExit = () => { |
| 400 | cleanup() |
| 401 | resolve(true) |
| 402 | } |
| 403 | |
| 404 | const cleanup = () => { |
| 405 | clearTimeout(timeout) |
| 406 | process.off('exit', onExit) |
| 407 | } |
| 408 | |
| 409 | process.on('exit', onExit) |
| 410 | }) |
| 411 | } |
| 412 | |
| 413 | export async function detachTmuxClient( |
| 414 | session: IsolatedTmuxSession, |
no test coverage detected