Skip to content

End the input-device watch and pactl subscribe with the shell - #16154

Closed
mrjamesmyers wants to merge 3 commits into
omacom:quattrofrom
mrjamesmyers:fix/OM45-302
Closed

mrjamesmyers wants to merge 3 commits into
omacom:quattrofrom
mrjamesmyers:fix/OM45-302

Conversation

@mrjamesmyers

Copy link
Copy Markdown
Contributor

Problem

Quickshell does not take its Process children along when it stops. PluginRegistry.qml documents this and reaps its own watcher at the next start (#15299); plugins/clipboard/Clipboard.qml:293,302 starts its wl-paste --watch children under setpriv --pdeathsig TERM. Two other long-running children of the shell have neither:

  • shell/Commons/InputDevices.qml:39-45: inotifywait -m on /dev/input, /dev and the udev data dir. On a quiet system it has no event to fail a write on, so after a shell restart or crash the old one stays under init until logout. test/shell.d/input-devices-test.sh already notes that Quickshell "leaves one running when it is stopped itself".
  • shell/Commons/UntypedInput.qml:130: pactl subscribe. It ends at the next audio event (SIGPIPE), so it is brief, but it is a second long-lived child with no owner.

The same leak showed up as 63 and 1002 orphaned watchers in #7150 for the plugin directory watcher. #11385 (open) is a pdeathsig PR for that watcher only.

Change

Prefix both commands with setpriv --pdeathsig TERM, exactly as Clipboard.qml does. setpriv execs the program, so the pid Quickshell sees is unchanged, and the deathsig survives the exec inotifywait inside the bash wrapper. No other behavior changes.

Not run: the QML was not started (no Linux box was used for this check). Runtime check: quickshell kill -p /usr/share/omarchy/shell, then pgrep -a inotifywait should show none with the /dev/input argument.

Found while testing Omarchy 4.5.0-rc1.

Quickshell does not take its Process children along when it stops. The
clipboard watchers already start under setpriv --pdeathsig TERM; the
inotifywait in Commons/InputDevices.qml and the pactl subscribe in
Commons/UntypedInput.qml did not, so each shell restart or crash left
them running under init. A quiet /dev/input gives the orphaned inotifywait
no event to fail a write on, so it stays until logout.

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

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds setpriv --pdeathsig TERM so inotifywait and pactl subscribe stop when Quickshell dies.

  • Quickshell's input watcher and audio listener stop when the shell exits.

Reviews (4) · Last reviewed commit: "Cover killed-shell watcher cleanup" · Reviewed by Greptile

@omarchybot omarchybot added the bug Something isn't working label Oct 22, 2026
A clean stop already kills these children: omarchy-restart-shell's quickshell kill reaps the old inotifywait on a worker, as Quickshell's Process destructor does. Only a shell that dies without running it (SIGKILL, Qt's _exit on a lost Wayland connection) orphans them, which is what setpriv covers, so the comments no longer say Quickshell never takes its children along.

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

Copy link
Copy Markdown
Collaborator

Thanks for this. I reproduced it on a disposable worker built from the Omarchy ISO, with this branch served by the live session, and the fix works for the deaths it covers. It does not yet cover Quickshell's own crash relaunch, the most common way the shell crashes.

What I ran, on base 03ff1eff3 and on this branch:

  • omarchy-restart-shell: the old inotifywait on /dev/input is gone afterwards on both. A clean stop already kills these children (Quickshell's Process destructor does it), so the "after a shell restart" half of the description doesn't happen.
  • kill -KILL of quickshell, relaunched by omarchy-launch-shell: on base the old inotifywait survives, reparented to the user manager. With a virtual default source set so pactl subscribe runs, the old pactl subscribe survives the same way. On this branch both are gone.
  • kill -SEGV within ten seconds of start, where Quickshell exits instead of relaunching itself: same result as SIGKILL, leaked on base and gone here.
  • kill -SEGV after the shell had been up 18 seconds: Quickshell logs "Quickshell has been restarted" and re-execs in the same process (pid 800 stayed alive). An exec isn't a parent death, so pdeathsig never fires, and on this branch the old watcher (1425) stayed running under pid 800 next to the new one. Clipboard.qml:269-280 covers this case with a pkill of leftover watchers before starting its own. Adding something similar here would also clean up watchers left by older builds, but it needs scoping so a test fixture shell can't kill the live session's watcher. Whether that belongs in this PR is a call for you and the maintainer.
  • ./test/cli passes, and so do the shell tests that touch these files: input-devices-test.sh 8/8, audio-test.sh 82/82, keyboard-layout-test.sh 64/64, shell-idle-spawn-test.sh 1/1, clipboard-test.sh 84/84.

Pushed: 8c6a9f1 rewrites the two new comments. They said Quickshell never takes its children along when it stops, which the restart test shows is false. Now they say setpriv ends the child if the shell is killed rather than stopped, in two lines. No code changed.

Also checked: setpriv comes from util-linux in base, so it is on every x86 and aarch64 install. It execs its target, so the pid Quickshell holds, the pgrep -P checks in input-devices-test.sh and LC_ALL=C for pactl are all unchanged. This branch merges cleanly with #16036, which edits nearby lines of UntypedInput.qml. #11385 makes the same change for the plugin watcher and doesn't overlap.

Second opinion: Codex Medium and muse-spark-1.3 (thinking high) reviewed it over two rounds. Codex found the in-place relaunch gap above, which I then confirmed on the worker. Both flagged the inaccurate comments. muse also suggested InputMethodState's indicator.py leaks the same way, which I dismissed: it exits when its stdin closes, and the worker showed it gone after the relaunch. On the final commit both found nothing left to act on, but their independence from my review is not guaranteed.

Next: this is labelled verified for the hard-kill case and waits on the maintainer to decide whether it lands as it stands or after a startup reap covers the in-place relaunch.

@simkaz12

Copy link
Copy Markdown

Field data for the hard-kill case. Omarchy 4.5.0-3, quickshell 0.3.2.r7.g2b4501a-1, NVIDIA RTX 5060 + AMD iGPU, one monitor.

The lock crash loop from #15438 ran for three days here and left 977, then another 981, orphaned inotifywait … /dev /dev/input /run/udev/data under systemd --user. That put the user at 1026 of 1024 inotify instances. The first symptom was EMFILE: too many open files, watch in an unrelated Node tool.

All 6210 shell deaths in that boot went through _exit(255) (The Wayland connection experienced a fatal error). None was an in-place relaunch: the journal has 0 Quickshell has been restarted lines. On this machine pdeathsig alone would have prevented every orphan, so the startup reap could be a follow-up.

I ran the same one-line change locally (exec setpriv --pdeathsig KILL inotifywait … inside the bash wrapper). Over 3 omarchy-restart-shell runs and 3 kill -KILL of quickshell, there was exactly one watcher after each restart, parented to the live shell, with none left under the user manager. Its pid stayed the same for 15 s within one shell's lifetime.

Bring the behavioral SIGKILL regression from omacom#19283 into the older fix so a watcher surviving its shell cannot silently return. Keep the fixture's explicit child cleanup independent of the guard it tests, including when an earlier assertion fails.

Co-Authored-By: Alex Muresan <a.muresan8533@gmail.com>
Co-Authored-By: GPT-6 High <noreply@openai.com>
Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
@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 Nov 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch now includes Alex Muresan's SIGKILL regression from #19283 in 1a6f1cd, with co-authorship credit. It waits for the fixture's input watcher, kills its owning Quickshell process, and checks that the watcher exits. The fixture retains explicit child cleanup so it can clean up even when the guard regresses.

On a fresh Omarchy ISO worker running this tree, I checked both actual production children, using a real Pipewire virtual source to activate pactl subscribe: both watchers survived a SIGKILL of their shell with the base commands, both exited with this branch's commands, and both survived again with the fix reverted. The two base modules are unchanged between this PR's original base and current quattro. The added regression also failed with the input-device fix reverted and passed on the final commit.

Worker checks passed: CLI 125, input devices 9, audio 82, audio-output-sink 16, keyboard layout 64, idle spawn 1, and clipboard 84. Four checks initially could not find Node through SSH; they passed after exposing the worker's installed mise runtime. The final worker QML and test files matched the committed files.

GPT-6 High in Codex reviewed the updated branch. Opus 5.5 High and muse-wonder via pi, thinking high reviewed the final commit and found no actionable defects. Opus's suggestion to retain explicit fixture cleanup is included; where the reviewers agreed, independence from my review is not guaranteed.

The previously documented in-place crash re-exec limitation remains: retaining the parent PID does not trigger the death signal. Startup cleanup remains separate follow-up work. #19283 stays open for the maintainer's decision.

The worker checks are complete. The ready label was refused because GitHub CI had not passed; its VM test was still running at the check. This remains verified, awaiting CI and the maintainer.

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

dhh commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Thank you @mrjamesmyers (and @dev-arekusandoru for the SIGKILL regression test)! Part of this overlap (startup reaping and Component.onDestruction cleanup) landed in #19968, and the remaining setpriv --pdeathsig TERM crash-termination fix for InputDevices.qml and UntypedInput.qml has been cleanly extracted with co-authorship credit into #19999.

@dhh dhh closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants