Commit 76f6b6d
Make Rust CLI ownership crash-safe on Windows (#2458)
* Fix CLI process tree lifecycle
Contain SDK-spawned CLI descendants in Unix process groups and Windows Job Objects, and terminate the complete owned tree during shutdown and failure cleanup.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Disarm process tree before root reap
Consume process-tree ownership during termination to prevent a second Unix signal after PID reuse, and make the Windows failed-start fixture execute through a PowerShell script.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Add real-CLI E2E coverage for descendant and host-crash scenarios
- Add stop_terminates_real_cli_wrapper_descendants: a Unix E2E test that
launches the real bundled CLI through a shell wrapper (via
ClientOptions::prefix_args) that backgrounds a descendant process, and
verifies Client::stop() kills that inherited descendant.
- Add abrupt_host_termination_still_kills_cli_via_job_object: a Windows
E2E test representing the actual github/app#2303 scenario -- an
SDK-embedding host process being killed/crashing abruptly, so none of
its own cleanup code (Client::stop/force_stop/Drop) ever runs. It
spawns a new copilot-host-crash-fixture helper binary that starts a
real CLI client and then never calls any SDK teardown code, terminates
that helper abruptly, and asserts the CLI still dies via the Job
Object's kill-on-close semantics.
Manually reproducing the same abrupt-kill scenario on Linux showed the
CLI already exits on its own within ~200ms once the OS closes the dead
host's end of the stdio pipe, with none of this crate's code involved --
a pre-existing, code-free safety net specific to stdio-piped processes
on Unix. That's further evidence Unix process-group containment isn't
needed to address #2303's failure mode, which is Windows-only.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(rust): narrow process ownership to Windows crash safety
Use a kill-on-close Job Object only on Windows and test that abruptly terminating the SDK host tears down its owned CLI process. Preserve direct-child behavior on other platforms.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* test(rust): focus process ownership coverage on Windows
Keep the real-CLI abrupt-host E2E and remove unsupported Unix descendant coverage and the redundant synthetic crash test.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>1 parent 6b0252c commit 76f6b6d
6 files changed
Lines changed: 471 additions & 25 deletions
File tree
- rust
- src
- tests
- e2e
- fixtures
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
| |||
105 | 111 | | |
106 | 112 | | |
107 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
108 | 121 | | |
109 | 122 | | |
110 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
1066 | 1067 | | |
1067 | 1068 | | |
1068 | 1069 | | |
| 1070 | + | |
1069 | 1071 | | |
1070 | 1072 | | |
1071 | 1073 | | |
| |||
1302 | 1304 | | |
1303 | 1305 | | |
1304 | 1306 | | |
| 1307 | + | |
1305 | 1308 | | |
1306 | 1309 | | |
1307 | 1310 | | |
| |||
1317 | 1320 | | |
1318 | 1321 | | |
1319 | 1322 | | |
1320 | | - | |
| 1323 | + | |
1321 | 1324 | | |
1322 | 1325 | | |
1323 | 1326 | | |
| |||
1334 | 1337 | | |
1335 | 1338 | | |
1336 | 1339 | | |
| 1340 | + | |
1337 | 1341 | | |
1338 | 1342 | | |
1339 | 1343 | | |
| |||
1346 | 1350 | | |
1347 | 1351 | | |
1348 | 1352 | | |
1349 | | - | |
| 1353 | + | |
1350 | 1354 | | |
1351 | 1355 | | |
1352 | 1356 | | |
| |||
1356 | 1360 | | |
1357 | 1361 | | |
1358 | 1362 | | |
| 1363 | + | |
1359 | 1364 | | |
1360 | 1365 | | |
1361 | 1366 | | |
| |||
1422 | 1427 | | |
1423 | 1428 | | |
1424 | 1429 | | |
| 1430 | + | |
1425 | 1431 | | |
1426 | 1432 | | |
1427 | 1433 | | |
| |||
1563 | 1569 | | |
1564 | 1570 | | |
1565 | 1571 | | |
| 1572 | + | |
1566 | 1573 | | |
1567 | 1574 | | |
1568 | 1575 | | |
| |||
1589 | 1596 | | |
1590 | 1597 | | |
1591 | 1598 | | |
| 1599 | + | |
1592 | 1600 | | |
1593 | 1601 | | |
1594 | 1602 | | |
| |||
1619 | 1627 | | |
1620 | 1628 | | |
1621 | 1629 | | |
| 1630 | + | |
1622 | 1631 | | |
1623 | 1632 | | |
1624 | 1633 | | |
| |||
1645 | 1654 | | |
1646 | 1655 | | |
1647 | 1656 | | |
| 1657 | + | |
1648 | 1658 | | |
1649 | 1659 | | |
1650 | 1660 | | |
| |||
1671 | 1681 | | |
1672 | 1682 | | |
1673 | 1683 | | |
| 1684 | + | |
1674 | 1685 | | |
1675 | 1686 | | |
1676 | 1687 | | |
| |||
1698 | 1709 | | |
1699 | 1710 | | |
1700 | 1711 | | |
| 1712 | + | |
1701 | 1713 | | |
1702 | 1714 | | |
1703 | 1715 | | |
| |||
1732 | 1744 | | |
1733 | 1745 | | |
1734 | 1746 | | |
| 1747 | + | |
1735 | 1748 | | |
1736 | 1749 | | |
1737 | 1750 | | |
| |||
1870 | 1883 | | |
1871 | 1884 | | |
1872 | 1885 | | |
1873 | | - | |
1874 | | - | |
1875 | | - | |
1876 | | - | |
1877 | | - | |
1878 | | - | |
1879 | | - | |
1880 | 1886 | | |
1881 | 1887 | | |
1882 | 1888 | | |
| |||
1933 | 1939 | | |
1934 | 1940 | | |
1935 | 1941 | | |
1936 | | - | |
| 1942 | + | |
1937 | 1943 | | |
1938 | 1944 | | |
1939 | 1945 | | |
| |||
1945 | 1951 | | |
1946 | 1952 | | |
1947 | 1953 | | |
1948 | | - | |
| 1954 | + | |
1949 | 1955 | | |
1950 | 1956 | | |
1951 | 1957 | | |
1952 | 1958 | | |
1953 | 1959 | | |
1954 | | - | |
| 1960 | + | |
1955 | 1961 | | |
1956 | 1962 | | |
1957 | 1963 | | |
1958 | 1964 | | |
1959 | 1965 | | |
1960 | 1966 | | |
1961 | 1967 | | |
1962 | | - | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
1963 | 1975 | | |
1964 | 1976 | | |
1965 | 1977 | | |
| |||
1971 | 1983 | | |
1972 | 1984 | | |
1973 | 1985 | | |
1974 | | - | |
| 1986 | + | |
1975 | 1987 | | |
1976 | 1988 | | |
1977 | 1989 | | |
| |||
2018 | 2030 | | |
2019 | 2031 | | |
2020 | 2032 | | |
2021 | | - | |
| 2033 | + | |
2022 | 2034 | | |
2023 | 2035 | | |
2024 | 2036 | | |
| |||
2561 | 2573 | | |
2562 | 2574 | | |
2563 | 2575 | | |
2564 | | - | |
2565 | | - | |
2566 | | - | |
2567 | | - | |
2568 | | - | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
2569 | 2582 | | |
2570 | 2583 | | |
2571 | 2584 | | |
| |||
2654 | 2667 | | |
2655 | 2668 | | |
2656 | 2669 | | |
| 2670 | + | |
2657 | 2671 | | |
2658 | 2672 | | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
2659 | 2678 | | |
2660 | 2679 | | |
2661 | 2680 | | |
| |||
2696 | 2715 | | |
2697 | 2716 | | |
2698 | 2717 | | |
2699 | | - | |
2700 | | - | |
2701 | | - | |
2702 | | - | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
2703 | 2721 | | |
2704 | 2722 | | |
2705 | 2723 | | |
| |||
2725 | 2743 | | |
2726 | 2744 | | |
2727 | 2745 | | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
2728 | 2751 | | |
2729 | 2752 | | |
2730 | 2753 | | |
| |||
2786 | 2809 | | |
2787 | 2810 | | |
2788 | 2811 | | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
2789 | 2818 | | |
2790 | | - | |
2791 | 2819 | | |
2792 | 2820 | | |
2793 | 2821 | | |
| |||
3447 | 3475 | | |
3448 | 3476 | | |
3449 | 3477 | | |
| 3478 | + | |
3450 | 3479 | | |
3451 | 3480 | | |
3452 | 3481 | | |
| |||
3536 | 3565 | | |
3537 | 3566 | | |
3538 | 3567 | | |
| 3568 | + | |
3539 | 3569 | | |
3540 | 3570 | | |
3541 | 3571 | | |
| |||
0 commit comments