(child)
| 514 | } |
| 515 | |
| 516 | function stopProcess(child) { |
| 517 | return new Promise((resolve, reject) => { |
| 518 | if (child.exitCode !== null || child.signalCode !== null) { |
| 519 | resolve(); |
| 520 | return; |
| 521 | } |
| 522 | |
| 523 | const timeout = setTimeout(() => { |
| 524 | child.kill("SIGKILL"); |
| 525 | reject(new Error("timed out waiting for computerd to exit")); |
| 526 | }, 2_000); |
| 527 | |
| 528 | child.once("exit", () => { |
| 529 | clearTimeout(timeout); |
| 530 | resolve(); |
| 531 | }); |
| 532 | |
| 533 | child.kill("SIGTERM"); |
| 534 | }); |
| 535 | } |