(child: Callable[[], NoReturn])
| 29 | |
| 30 | |
| 31 | def fork_process(child: Callable[[], NoReturn]) -> int: # pragma: win32 no cover |
| 32 | if _FORK is None: # pragma: no cover - platform without os.fork |
| 33 | msg = "os.fork is unavailable" |
| 34 | raise RuntimeError(msg) |
| 35 | child_pid = _FORK() |
| 36 | if child_pid == 0: # pragma: forked child |
| 37 | # A child that raises or returns must never resume the parent's test run. |
| 38 | try: |
| 39 | child() |
| 40 | except BaseException: |
| 41 | traceback.print_exc() |
| 42 | exit_child(70) |
| 43 | return child_pid |
| 44 | |
| 45 | |
| 46 | def exit_child(status: int) -> NoReturn: |