Execute a binary, replacing the current process on Unix. On Windows, ``os.execv`` does not truly replace the process — CPython's MSVC implementation spawns a child process instead. This breaks console handle inheritance and prevents the Rust TUI from receiving keyboard input (see #
(binary: str, argv: list[str])
| 25 | |
| 26 | |
| 27 | def _exec_binary(binary: str, argv: list[str]) -> None: |
| 28 | """Execute a binary, replacing the current process on Unix. |
| 29 | |
| 30 | On Windows, ``os.execv`` does not truly replace the process — CPython's |
| 31 | MSVC implementation spawns a child process instead. This breaks console |
| 32 | handle inheritance and prevents the Rust TUI from receiving keyboard |
| 33 | input (see #587). We use ``subprocess.call`` on Windows to work around |
| 34 | this. |
| 35 | """ |
| 36 | if sys.platform == "win32": |
| 37 | sys.exit(subprocess.call([binary] + argv)) |
| 38 | else: |
| 39 | os.execv(binary, [binary] + argv) |
| 40 | |
| 41 | |
| 42 | def main(): |