Skip to content

Reap orphaned plugin watchers at shell start - #15299

Merged
dhh merged 3 commits into
quattrofrom
fix/plugin-watcher-orphans
Oct 14, 2026
Merged

dhh merged 3 commits into
quattrofrom
fix/plugin-watcher-orphans

Conversation

@dhh

@dhh dhh commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

What

Quickshell does not take its Process children with it when it stops, so every shell restart left the plugin-directory inotifywait (PluginRegistry.localPluginWatcher) running, reparented to init — 79 on this machine (the runtime-smoke test already works around the same leak for its scratch shells).

  • Component.onDestruction: stop the restart timer and the watcher on a graceful stop.
  • Startup: before starting its own watcher, the shell reaps any inotifywait that watches this shell's plugins directory but whose parent is no longer a shell. A live shell's watcher (parented to it) and watchers of other directories are left alone.

Verification

  • New test/shell.d/plugin-watcher-reap-test.sh: lifecycle wiring, orphan reaped, unrelated-directory watcher spared, live shell's watcher spared. Running it here took the machine from 81 plugin watchers to the one live shell's.
  • Codex review: first pass required restricting the reap to watchers of this plugins directory (an unrelated inotifywait with the same flags was being killed); fixed and re-reviewed clean.

From plans/overnight-quality.md §3 (orphaned plugin watchers).

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous test findings are fixed.

Summary

The shell now stops its plugin watcher on graceful shutdown and removes orphaned watchers before starting a replacement.

  • Plugin watcher restarts no longer leave old watchers behind.

Reviews (3) · Last reviewed commit: "Keep the reaped-watcher checks honest ab..." · Reviewed by Greptile

Comment thread shell/services/PluginRegistry.qml Resolved
@dhh

dhh commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Greptile addressed in the latest commit:

  • P1 (unrelated watchers): the reap now matches the watched directory as a whole command-line argument (grep -Fxq over the NUL-split cmdline); a watcher of plugins-backup survives — covered by a new test case.
  • P2 (lost watchers become skips): the test now creates a controlled live watcher (stand-in process named quickshell, no desktop session needed) and finds it before the reap, then asserts the same pid survives.
  • P2 (tests run different code): the test extracts the reap command from PluginRegistry.qml at runtime instead of running a copy, so breaking the real command fails the behavior checks.

plugin-watcher-reap-test.sh passes (5 checks).

@dhh

dhh commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Greptile round 2 addressed: the stand-in parent now polls its child (no zombie false-survivor), the test asserts the survivor is not a zombie, and the cleanup trap tolerates pkill finding nothing. Test passes.

dhh added 3 commits October 14, 2026 03:22
Quickshell does not take its Process children with it when it stops,
so every shell restart left the plugin-directory inotifywait running,
reparented to init — 79 of them on one machine. Stop the watcher on a
graceful destruction, and at startup, before starting our own, stop
any plugin watcher whose parent is no longer a shell. A live shell's
watcher, parented to it, is spared.
Greptile: a substring match also caught a watcher of
plugins-backup; the test copied the reap instead of running it and
only looked for a live watcher after reaping. The reaper now matches
a whole command-line argument, and the test extracts the real reap
command from PluginRegistry.qml, finds its live watcher (a stand-in
named quickshell) before reaping, and checks it and a similarly
named directory's watcher survive.
Greptile: the stand-in parent never waited, so a killed watcher
could linger as a zombie that kill -0 still sees; poll the child,
check the survivor is not a zombie, and let the cleanup trap run
when pkill finds nothing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants