改动 / #3254
#3254 [TUI] procs: find engine orphans adopted by systemd --user, and wait until they are really gone
open · @toel1234 · 0 评论 · 去 GitHub 看
说明
## Problem and result On a systemd Linux desktop, `strata` never found an engine left behind by an earlier run without a launch record. `systemd --user` both adopts orphans (subreaper) and is an ancestor of every desktop terminal. `orphans_of()` put every ancestor except pid 1 into "my own processes", so an orphan whose new parent is `systemd --user` looked started by this server and was skipped. The orphan kept holding the GPU. After that was fixed, a second Linux issue showed: `end_one()` returned "ended" while the process was still exiting. It waited on `is_same()` (start token and command line), and an exiting Linux process has an empty `/proc/<pid>/cmdline` before it is gone. After: ancestors named like an init (`INIT_NAMES`, already used for the adopted-parent check) are not counted as starters, the same as pid 1. After the signal, `end_one()` waits on the start token alone, which is unique per process lifetime and never matches a reused PID. The kill itself is still only sent after the full `is_same()` check. ## Related discussion none. Focused fix. ## Approach Two small changes in `strata_control/procs.py`. Both are needed for the existing test `test_an_engine_orphan_of_this_executable_is_found_and_a_live_one_is_not`: with only the first it still fails (process reported ended, start token still live), with both it passes. Windows behaviour is unchanged apart from the wait loop now comparing the start token, which is the same value `is_same()` compared first. ## Validation **Passed:** - `python -m pytest tests/terminal/test_procs.py` 5 times in a row: 7 passed each. Ubuntu, GNOME on Wayland, Python 3.12.3, the process tree `systemd(1) > systemd --user > gnome-shell > … > pytest`. - Full `python -m pytest tests/terminal -q` with this branch and #3255 merged: 852 passed, 17 skipped, 0 failed (445.96 s). - Diagnosis: an orphan of this test is reparented to `systemd --user` (pid 5687 here), which `psutil.Process().parents()` also lists. **Failed:** none observed. **Not run:** - Windows and macOS: not available. The Windows branch of `end_one()` only changes which check the wait loop uses. - A real engine orphan: tested with the existing Python sleeper fixture only. ## Limits A process stuck in exit (empty command line, start token still live) is now reported "stuck" after the 10 s wait instead of "ended". 🤖 Generated with [Claude Code](https://claude.com/claude-code)
本站相关内容
相关页面的快捷入口。