Skip to content

Stop the test shell's whole process group so its plugin watcher dies with it - #14545

Open
omarchybot wants to merge 6 commits into
quattrofrom
fix/issue-7124
Open

omarchybot wants to merge 6 commits into
quattrofrom
fix/issue-7124

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

Every ./test/shell run left orphaned inotifywait -m -r processes behind, reparented to init, each watching a fixture home the test had already deleted and holding the harness's inherited descriptors, the run-shell-tests lock among them. A later run could then block on a lock held by a process that outlived the suite that took it.

The shell tests start Quickshell in the background and stop it with kill "$QS_PID", which signals Quickshell alone. Quickshell exits on SIGTERM without reaping its Process children, so PluginRegistry's localPluginWatcher (shell/services/PluginRegistry.qml:663) survives it. plugin-registry-contract-test.sh and screenshot-sanity-test.sh each leave one per run.

The twelve tests that start a background Quickshell now start it under setsid and stop it with stop_process_group, a new helper in base-test.sh that kills the whole group and then waits on the shell. In these non-interactive scripts the background job is never a group leader, so setsid execs in place and $! is both the shell's pid and its group id; the group is separate from the test's own, so the kill cannot reach the test or the harness. Cleanup no longer checks kill -0 against the shell's pid first, so the children of a shell that already crashed are still stopped.

This fixes the tests, not PluginRegistry.qml. The live session does not leak, because omarchy-restart-shell takes the shell down gracefully, and a group kill covers every child a test shell starts rather than this one watcher. background-intro-clone-test.sh and background-instant-reload-test.sh keep their own teardown: their fixtures quit on their own, and their children are short helpers rather than an indefinite watcher.

Reproduced on a disposable Omarchy worker VM with a Hyprland session. On quattro at 902fd8a, the full shell suite left two orphaned watchers; run singly, plugin-registry-contract and screenshot-sanity left one each. On this branch the full suite and each of those tests left none. All twelve changed tests pass. Reviewed by Claude Opus 5.5 and by Codex Medium as a second opinion; Codex found no defect, checked the setsid fork condition against util-linux's source, and agreed the change is proportionate. Its independence from the first review is not guaranteed.

Fixes #7124

Shell tests stopped a background Quickshell with SIGTERM to its pid alone. Quickshell exits without reaping its Process children, so PluginRegistry's inotifywait plugin watcher was reparented to init and lived on, watching a deleted fixture home and holding the harness's inherited descriptors, the run-shell-tests lock among them. plugin-registry-contract and screenshot-sanity each left one per run.

Start Quickshell under setsid and stop it with a group kill. The kill no longer waits on kill -0 against the shell's pid, so a shell that already died still has its children cleaned up.

Fixes #7124

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

The PR puts QML fixtures and the tray-menu test’s Quickshell in separate process groups. Cleanup stops those groups, including children left behind after Quickshell crashes.

  • Adds a TERM grace period followed by KILL.
  • Extends the plugin-registry test to cover a crashed shell with a stopped watcher.
  • No actionable issues found. Runtime tests were not run during this review.

Reviews (5) · Last reviewed commit: "Merge quattro to pick up the default age..." · Reviewed by Greptile

runtime-smoke-test.sh takes quattro's version: it now sweeps every process carrying the test's scratch OMARCHY_PATH after stopping the shell, with a KILL fallback, which already covers the watcher this branch stops with a group kill. The other eleven tests keep the group kill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Brought this across to current quattro (51bfd1d) with a merge, 09dbb49, since the branch no longer merged cleanly.

The merge. The one conflict was test/shell.d/runtime-smoke-test.sh. quattro has since given that test its own cleanup: after stopping the shell it stops every process carrying the test's scratch OMARCHY_PATH, with a KILL fallback, which already covers the watcher. That file now matches quattro, so the branch changes eleven tests plus the stop_process_group helper in base-test.sh, not the twelve the description names. The startup reaper quattro added to PluginRegistry.qml does not cover this: it only reaps watchers of the shell's own plugins directory, and each test's directory is a temporary one. The tests added since (bar-drag, remote-session-service) were run on quattro and leave no orphans, so they are left alone.

What ran, on a disposable Omarchy worker VM with a Hyprland session:

  • On quattro, plugin-registry-contract-test.sh and screenshot-sanity-test.sh each left one orphaned plugin inotifywait, reparented to init. The full ./test/shell run left five: two plugin watchers and three /dev/input watchers.
  • On this head, all eleven changed tests pass and the full ./test/shell run left none. quattro is this head with the fix reverted, so the first run is also the reverted run.
  • ./test/cli passes.
  • ./test/shell has the same six failures on quattro and on this head: lock-appear-budget, passwordless-grant-lifecycle, runtime-smoke (keepLoaded IPC) and three more. None of them is in a file this changes. They are why this is labelled verified and not ready.

Second opinion: Codex Medium, given the ported diff. It found no defect. It agreed the runtime-smoke resolution is right and that no other test on this head still leaks a long-lived child; that agreement is not guaranteed independent of this review. It noted that setsid forks rather than execs if job control is on inside a test (bash -m, or monitor in an exported SHELLOPTS), and then $! would not be the group. test/shell and the worker wrapper both run each file with plain bash, so that does not happen here.

Related: #11385 adds setpriv --pdeathsig TERM to the plugin watcher itself, for the production crash path in #11383. Codex judged the two complementary rather than competing, and so does this review: that one makes the watcher die with a crashed shell, while this one cleans up every child of a test shell, including the /dev/input watchers #11385 does not touch.

Waiting on the maintainer: the six pre-existing ./test/shell failures on quattro keep this from ready.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 29, 2026
quattro moved nine of the tests this branch changed onto the shared run_qml_fixture harness in base-test.sh (#16339), and deleted lock-password-overflow-test.sh and screenshot-sanity-test.sh. Those files now match quattro, and the fix moves into the harness instead: run_qml_fixture starts Quickshell under setsid, and both its re-run and qml_fixture_cleanup stop the whole group with stop_process_group, so every run_qml_fixture test is covered at once. tray-menu-test.sh still starts its own shell and keeps the per-test fix. The scratch-shell tests, input-devices-test.sh and shell-idle-spawn-test.sh already stop their own children.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Brought this across to current quattro (bbfdfdd) with a merge, 9fbbd7d. The branch had stopped merging cleanly.

The merge. #16339 moved nine of the tests this branch changed onto a shared run_qml_fixture harness in test/shell.d/base-test.sh, and quattro has since deleted lock-password-overflow-test.sh and screenshot-sanity-test.sh. Those files now match quattro, and the fix moves into the harness: run_qml_fixture starts Quickshell under setsid, and both its re-run and qml_fixture_cleanup stop the whole group with stop_process_group. That covers every run_qml_fixture test at once, the ones added since included. tray-menu-test.sh still starts its own shell and keeps its own fix. Against quattro, the branch now changes only base-test.sh and tray-menu-test.sh. The description above still lists the twelve files it changed before quattro moved those tests. The scratch-shell helpers, input-devices-test.sh and shell-idle-spawn-test.sh already stop their own children, so they are left alone.

What ran, on a disposable Omarchy worker VM with a Hyprland session:

  • On quattro, plugin-registry-contract-test.sh left an orphaned plugin-directory inotifywait, and manifest-entrypoints-test.sh left an orphaned /dev/input inotifywait, both reparented to init. On this head, neither test left anything. quattro is this head with the fix reverted, so that run is also the reverted run.
  • The full ./test/shell run left three orphans on quattro and none on this head.
  • ./test/cli passes.
  • ./test/shell has the same five failing files on quattro and on this head: agent-account-exec, ascii, branding-about-animation, first-run and runtime-smoke. This change touches none of them.

Second opinion: Codex Medium and muse-wonder via pi, thinking high, given the ported diff. Neither found a defect. Both confirmed that $! is the new group in these non-interactive scripts and that the guards cannot trip set -e. Their agreement may not be independent of this review. Codex noted a theoretical race: a group signal could hit an unrelated group if the shell's whole group had already gone and its number were reused before cleanup ran. That needs the pid counter to wrap within that short window, and no test holds a stale pid for long, so it is not acted on.

Related: #11385 and #16154 add setpriv --pdeathsig TERM to the plugin watcher and the input-device watcher in the shell itself. They are complementary: they fix a crashed live shell, and this fixes test teardown.

Waiting on the maintainer. The five failures above already fail on quattro, and they keep this from ready.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

This has stopped merging cleanly again, and this time I have not brought it across: quattro now fixes #7124 itself, so there is nothing left here worth porting.

What fixed it. 48956c8 (#17388) changed qml_fixture_cleanup in test/shell.d/base-test.sh to list Quickshell's whole process tree with pgrep -P and kill all of it, not just Quickshell, and to retry removing the scratch directory. Every run_qml_fixture test goes through that cleanup, including the two this pull request was fixing.

What ran, on a disposable Omarchy worker VM with a Hyprland session:

  • On the old base (bbfdfdd), plugin-registry-contract-test.sh still left an orphaned plugin-directory inotifywait and manifest-entrypoints-test.sh an orphaned /dev/input one, both reparented to init. This was the control, to show the check catches a leak.
  • On current quattro (3b36b9e), neither test left anything, and the full ./test/shell run left no orphaned watchers. That run had 7610 passing and 5 failing files, none of them related to this.

What this pull request still has that quattro does not, none of it hit by any current test:

  • The "second fixture in the same file" stop in run_qml_fixture still kills only Quickshell. No test calls run_qml_fixture more than once, so this never runs.
  • A process-group kill would also catch children of a Quickshell that had already exited, and it has no pgrep race. bar-drag's fixture quits 200 ms after writing its result, so that ordering can happen, but no leak from it showed up.
  • tray-menu-test.sh starts its own Quickshell. Its fixture only runs a short execDetached result writer, not a watcher, so killing Quickshell alone leaves nothing behind.

Second opinion: Codex Medium, asked from the code alone whether quattro already fixes #7124. It agreed that it does and that this can be closed as superseded. It also found the execDetached writer and the bar-drag early quit noted above. It treats the group kill as optional hardening, not a missing fix. Its independence from this review is not guaranteed.

Waiting on the maintainer, with a recommendation to close this, and #7124 with it, since 48956c8 fixed it on quattro. If you'd rather have the group-kill hardening, it can come back as a small pull request on top of #17388's cleanup.

omarchybot and others added 2 commits November 22, 2026 19:09
Keep current fixture cleanup and tray coverage while stopping children after Quickshell crashes. Fold the TERM grace period and KILL fallback from #17392 into the shared process-group helper, waiting for Quickshell only after escalation so an unresponsive leader cannot hang cleanup. Exercise a real plugin watcher stopped before its Quickshell is killed, proving cleanup reaches orphaned children and escalates when TERM cannot run.

Co-Authored-By: David Heinemeier Hansson <david@hey.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
The registry fixture can write its result before the asynchronous watcher startup chain finishes. Wait up to three seconds for the real child before killing Quickshell, so scheduler delays do not turn the cleanup regression into a startup race.

Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Updated this branch onto quattro at c79f693, with #17392’s group-drain wait and KILL fallback folded into stop_process_group. The merge commit credits its original commit author, David Heinemeier Hansson. Cleanup now reaches children after Quickshell has died, waits briefly for them, and escalates before waiting for the leader. The newer tray mock cleanup and scratch-directory removal retries are preserved.

Verified on a disposable Omarchy worker with a real Hyprland session. The regression test starts the real plugin-registry fixture, stops its inotifywait watcher and kills Quickshell. The watcher survives cleanup on the base, is stopped on this head, and survives again with the fix reverted. Removing only the KILL fallback also makes the test fail. The test waits for asynchronous watcher startup before exercising cleanup.

./test/cli passes. The final ./test/shell run completes 433 of 438 files without failure; six files contain skipped checks. The five failing files also fail the same assertions on the tested quattro base: ascii, branding-about-animation, provision-owner-keyboard, remote-session-service and runtime-smoke. None is changed by this PR. Greptile reviewed head 3503851 at 5/5 with no findings.

Checked by GPT-6 in Codex (reasoning effort not exposed), with reviews by Opus 5.5 High and muse-wonder via pi, thinking high. Opus found the watcher-start race addressed by the bounded wait; both reviewers found no defects on the final head. Their agreement is not guaranteed independent of this review.

Waiting on the maintainer for the five failures already present on the base. The change is labelled verified; the ready command refuses it because the worker suite is not fully green.

@omarchybot

Copy link
Copy Markdown
Collaborator Author

CI run 45054685184 failed only default-agent-test.sh, with “omarchy-shell is not running.” It tested merge commit e238ee041d, which included a base-branch test defect: the test removed its omarchy-shell stub before a later --pick --prompt call, so that call reached the real shell. The test and bin/omarchy-agent are unchanged between that CI base and the merge, and this test never calls the fixture cleanup changed here. quattro fixed the stub lifetime in 7d696f7 (#19791).

On a fresh disposable Omarchy worker with Hyprland, the test fails the same way at both the CI base (cb13df1139) and the exact CI merge. It passes at this PR’s unchanged head (3503851a291006581eeb89acdf347e914b3f5e08) and at current quattro (f989b43e91). These were focused runs of the failed file; the full suite was not rerun.

Checked by GPT-6 in Codex (reasoning effort not exposed), with Opus 5.5 High and muse-wonder via pi, thinking high. Both reviewers agreed with the cause and disposition; their agreement is not guaranteed independent of this review. Nothing was pushed and CI was not rerun. The existing verified evidence remains; this is waiting on the maintainer because CI remains red and the earlier full-suite blockers remain unresolved.

CI run 45054685184 tested a base that removed the omarchy-shell stub before the default agent picker called it. Worker bisect found 7d696f7 keeps the stub through that call and fixes the failure. Merge the fixed base to test the PR alongside that correction.

The worker CLI suite and the focused default-agent, plugin-registry and tray tests pass. The same assertions fail on the merged tree and current quattro in agent-resume-test.sh, provision-owner-keyboard-test.sh and runtime-smoke-test.sh.
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Dec 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Recommend: Hold — three shell tests still fail on the worker, including on quattro, and need the maintainer’s assessment.

I merged quattro into this branch at 4cb0ce9a3a. A worker bisect identified #19791 as the fix for the old default-agent-test.sh failure. All four GitHub test jobs passed on the updated branch. GitHub Actions run

On a disposable worker, the plugin-watcher regression failed on quattro and with the cleanup reverted, and passed on this commit. The CLI and focused tests passed. The full shell suite hit the same three assertions on both revisions, in agent-resume-test.sh, provision-owner-keyboard-test.sh, and runtime-smoke-test.sh.

GPT-6.2 Sol High in Codex checked the results. Opus 5.5 High and muse-wonder via pi, thinking high, reviewed the merge tree, and Opus 5.5 High found no actionable issues in the final review. The reviewers could access the driver’s work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test/shell leaks two orphaned inotifywait processes per run, holding the harness's file descriptors

1 participant