omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Quitting the speedtest midway leaves orphan processes

Open SystJF opened this issue 3 months ago • 10 comments

System details

Quattro

What's wrong?

  1. Run a speed test
  2. Quit before the "Run again" button pops up by clicking anywhere on the screen
  3. "omarchy-network-speedtest" processes remain active

SystJF avatar Aug 15 '26 15:08 SystJF

Confirmed on Omarchy 4.0.0-1.

I reproduced this twice:

  1. Start the built-in network speed test.
  2. Close the speed-test panel before it finishes.
  3. The panel disappears, but the internet connection remains very slow.

After closing the panel, multiple /bin/bash /usr/share/omarchy/bin/omarchy-network-speedtest down processes remained active for several minutes and did not exit on their own. During the second reproduction, I observed seven such processes together with seven active curl processes downloading from *.nflxvideo.net/speedtest.

Normal performance returned only after manually stopping those processes.

After cleaning up, I left the system running without opening the speed test again. The processes did not return and the problem did not recur.

jfg96 avatar Aug 17 '26 23:08 jfg96

Hit this too on 4.0.0.alpha (omarchy 4.0.0-1, quickshell-git 0.3.0.r20.g28771c7-1), launched from the UI panel. Seven orphaned omarchy-network-speedtest down workers survived for 31 minutes, pulling a sustained ~300 Mbit/s the whole time. They had been reparented to systemd --user.

Some root-cause detail that might help:

The workers have no lifetime bound of their own. In /usr/bin/omarchy-network-speedtest, traffic_worker is an unbounded loop:

while true; do
  url=${urls[$((idx % url_count))]}
  curl -fsS -o /dev/null "$url" 2>/dev/null || return
  idx=$((idx + 1))
done

There is no duration cap anywhere in the script — not on the worker loop, not on the individual curl, and not on the test overall. The run is terminated only by the consumer killing the parent, and cleanup happens only via trap cleanup EXIT in the parent. So the workers' entire lifetime depends on the parent dying gracefully.

That makes any abnormal parent death leak all 8 workers, permanently. Deterministic repro:

$ omarchy-network-speedtest down >/dev/null 2>&1 &
$ P=$!; sleep 6
$ pgrep -P $P | wc -l
9
$ kill -9 $P          # parent dies without running its EXIT trap
$ sleep 3
$ pgrep -f nflxvideo | wc -l
10

The workers keep going indefinitely — measured at 369 Mbit/s still flowing after the parent was gone. They never stop on their own, because nothing tells them to.

For what it's worth, a plain SIGTERM to the parent (the normal panel-dismissal path) cleaned up correctly in 6/6 trials here, so the EXIT trap itself works when it gets to run. The leak is about the cases where it doesn't: SIGKILL, a quickshell/panel crash or restart, OOM kill, session teardown, or a SIGKILL following a SIGTERM timeout. Panel.qml already notes dismissal signalling is racy ("A dismissal's SIGTERM is still in flight; Process.running stays true").

Suggested hardening — make the workers safe in isolation, so no signal path can leave unbounded traffic running:

  1. Give each worker a self-imposed deadline, so an orphan expires on its own:
    local deadline=$((SECONDS + 30))
    while (( SECONDS < deadline )); do ...; done
    
  2. Bound each request with curl --max-time, so a single stalled transfer can't run forever.
  3. Optionally start the workers in their own process group (setsid) and kill the group in cleanup, rather than walking PIDs.

(1) alone converts this from "leaks at line rate forever" into "leaks for at most one test duration", which seems worth having regardless of how the signalling races resolve.

Workaround in the meantime:

pkill -f omarchy-network-speedtest

igor-gorohovsky avatar Aug 18 '26 08:08 igor-gorohovsky

Confirmed on Omarchy 4.0.0-1 (stable), with another trigger and a fairly severe real-world impact.

Restarting Omarchy Shell while the upload phase is running also leaves the speed-test backend orphaned.

Observed timeline:

  • 20:19:37: /usr/share/omarchy/bin/omarchy-network-speedtest up started
  • 20:19:39: Omarchy Shell logged Exiting due to IPC request and restarted
  • The speed-test process was reparented to the systemd user manager and continued running
  • Approximately 33 minutes later it still had 8 curl upload workers active
  • The interface counter had reached approximately 126.7 GB transmitted
  • Manually terminating the speed-test process stopped the traffic immediately

The backend loops indefinitely and appears to rely entirely on the QML Timer (interval: 5000) setting Process.running = false. If the overlay or entire shell disappears before that timer fires, nothing imposes a deadline on the backend process.

A backend-enforced maximum duration would make this safe even if the UI crashes, is dismissed, or restarts. Cleanup on overlay destruction would still be useful, but the backend should probably not be capable of uploading indefinitely by itself.

flrsn avatar Aug 21 '26 19:08 flrsn

Confirmed still present on Omarchy 4.0.1-1 (quickshell 0.3.1-1), launched from the omarchy.speedtest panel.

After dismissing the overlay, six leftover /bin/bash …/omarchy-network-speedtest down workers plus matching curl processes to *.nflxvideo.net/speedtest stayed up for ~8 minutes. They had been reparented to systemd --user (ppid 952) and were no longer children of quickshell. Closing the overlay had no remaining handle on them.

A terminal SIGTERM to the parent does reap the workers here — the EXIT trap runs. The dismiss path is harsher than that:

  • omarchy.speedtest is not keepLoaded.
  • shell.hide() calls close() (Process.running = false → SIGTERM) and then immediately drops the id from openPanelIds.
  • The panel Loader goes inactive and destroys the Process object.
  • Qt's QProcess destructor kills a still-running child with SIGKILL, so the parent's EXIT trap is cut off mid-cleanup and the eight unbounded traffic_worker loops get adopted by systemd.

That matches the original "click anywhere to dismiss" repro, and why a clean SIGTERM from a shell does not. The workers themselves are while true with no duration cap and no --max-time, so they keep saturating the link until something kills them.

#7598 already bounds each worker (parent check + --max-time + 30s lifetime). That turns an unbounded leak into a short one; it does not change the panel unload / SIGKILL race.

Workaround: pkill -f omarchy-network-speedtest

NiftyImages avatar Aug 25 '26 21:08 NiftyImages

Confirmed on Omarchy 4.0.1-1 (kernel 7.1.9-arch1-2, quickshell 0.3.1-1), with a deterministic repro through the normal UI dismissal path — no crash or shell restart involved.

Original incident: 7 orphaned omarchy-network-speedtest down workers reparented to systemd --user, saturating the link at ~440 Mbit/s for 47 minutes until killed manually. Quickshell had not restarted (same PID, up for 1d5h), so this was pure panel dismissal.

Deterministic repro (leaks every time on my machine):

omarchy-shell shell summon omarchy.speedtest
sleep 7                                       # dismiss mid-phase
omarchy-shell shell hide omarchy.speedtest

Result: 7 orphaned omarchy-network-speedtest up bash workers with PPID = systemd --user, each looping curl -X POST uploads to *.oca.nflxvideo.net indefinitely.

Two data points that narrow the root cause:

  1. The automatic down→up phase transition at the 5 s mark cleaned up correctly in the same run — no down workers survived. That transition uses the same Process.running = false mechanism (stopPhase() in Panel.qml), so graceful stop works.
  2. A manual SIGTERM to the parent script also ran the EXIT trap and reaped all workers (matches @igor-gorohovsky's 6/6 above).

So the leak is specific to panel dismissal/teardown: shell.hide destroys the panel, and the Process's child appears to die without its EXIT trap running — consistent with a SIGKILL from QProcess destruction (or a kill racing the in-flight cleanup), rather than the trap being generally broken.

+1 to a backend-enforced deadline (worker self-expiry and/or curl --max-time): no signalling fix in QML can cover the SIGKILL paths, and it would also resolve the quickshell-restart variant in #8515.

janoguerra avatar Aug 29 '26 03:08 janoguerra

Reproduced this on Omarchy 4.0.1-1 (quickshell 0.3.1-1, Hyprland 0.56.2) and tracked down the mechanism. Posting it here rather than in the duplicate I opened by mistake (#9207, now closed). Related: #8515 reports the same orphaning via a different trigger.

It isn't specific to clicking away mid-run — an ordinary dismissal at any point leaks, and it does so with Quickshell perfectly healthy (mine had been up 23h, no restart, no crash):

omarchy-shell shell summon omarchy.speedtest '{}'
sleep 7                                    # past the 5s download phase, into the upload phase
omarchy-shell shell hide omarchy.speedtest # same path as the overlay's close button
sleep 4
ps -e -o pid=,ppid=,cmd= | grep -F '/omarchy-network-speedtest' | grep -v grep

6 of the 8 workers survive, reparented to systemd --user, each still looping 64 MB POSTs to Netflix OCAs indefinitely.

Cause: a teardown race in hide(), not a missing SIGTERM

  • The script forks 8 workers and relies on trap cleanup EXIT (bin/omarchy-network-speedtest:55-67) to reap them.
  • plugins/panels/speedtest/Panel.qml:50-62 close() is correct — speedTestProc.running = false sends SIGTERM.
  • But shell.qml:480-494 hide() calls close() and then drops the id from openPanelIds in the same event-loop turn. That flips the Loader's active binding (shell.qml:625) to false, destroying the panel Item — and its Process — while bash is still shutting down.
  • The script can't respond instantly: it's blocked in sleep 1 in its sampling loop (:108-128), so it needs up to ~1s to reach the trap. It never gets that long.

Verified both directions in isolation: SIGTERM to the script alone cleans up perfectly (0 orphans, trap runs); SIGKILL reproduces the exact orphan signature. So the delivery mechanism is fine — the process is simply destroyed before the trap can run. The speedtest manifest doesn't set keepLoaded, so it's on the destroy-on-hide path.

This matters for the fix: #8515's parent-death guard would handle the crash/restart case there, but not this one — the parent (quickshell) never dies, so a kill -0 $PPID poll never fires.

Possible fixes

  1. "keepLoaded": true in plugins/panels/speedtest/manifest.json, so the Item survives the hide and close()'s SIGTERM lands. One line, covers only this panel.
  2. Harden the script — trap cleanup EXIT INT TERM HUP, and put the workers in their own process group so a hard kill takes the children with it. Fixes it for any caller.
  3. More generally, have hide() let a plugin finish closing before the Loader is deactivated. Any plugin that spawns a Process is exposed to the same race.

Recovery in the meantime is pkill -f omarchy-network-speedtest.

orospakr avatar Aug 30 '26 17:08 orospakr

Open PR #9344 fixes the normal panel-dismissal race described here. It marks both speed-test panels keepLoaded so hiding the panel does not destroy the Process object before SIGTERM and the existing exit cleanup finish; it adds lifecycle coverage and reproduces the orphan workers before and after. Scope caveat: this fixes ordinary dismissal, not the full Quickshell crash or SIGKILL path tracked separately in #8515.

rookepoole avatar Sep 01 '26 09:09 rookepoole

Checked against current quattro (902fd8a) by Claude Opus 5.5, with Codex Medium as a second opinion. Both found the leak still present there, by reading the code; it was not reproduced on a worker for this issue, since both pull requests below were each reproduced on a disposable Omarchy ISO worker before and after their change.

Cause. Dismissing the panel goes through hide() in shell/shell.qml, which calls the panel's close() (SIGTERM to the script) and then drops it from openPanelIds in the same turn. That unloads the panel and destroys its Process, and Quickshell's Process destructor kills a still-running child with SIGKILL, so the script's EXIT trap in bin/omarchy-network-speedtest never finishes stopping its workers. The workers are while true loops around curl with no time limit, so once orphaned they run until killed. Codex added that a Quickshell restart or a plugin reload reaches the same destructor, and a direct SIGKILL of the script leaks the same way.

Fixes already open, which complement each other rather than compete:

  • #9344 marks the network and disk speed-test panels keepLoaded, so the Process survives hide() and the EXIT trap finishes. That fixes ordinary dismissal, the path reported here.
  • #7598 bounds the workers themselves: each checks that the script is still alive, every transfer has curl --max-time, and every worker has a 30s lifetime. That limits any path that skips cleanup, including a SIGKILL or a shell restart, to a short leak rather than an endless one.

Both already name this issue, so it closes when either merges. Which to take, or both, is the maintainer's decision; nothing is needed from the reporters. Until then, pkill -f omarchy-network-speedtest stops leftover workers.

omarchybot avatar Oct 08 '26 04:10 omarchybot

One more data point, relevant to choosing among the open fixes. Omarchy 4.0.4-1.

Found four omarchy-network-speedtest down supervisor scripts that had been running for ~6 minutes, all started in the same second, all reparented to systemd --user. Each had live curl workers pulling from *.oca.nflxvideo.net/speedtest, together saturating a 2.4 GHz link (~65 Mbit/s) and pushing gateway RTT from ~6 ms to ~25 ms with 3–7% loss.

Notably, Quickshell had not crashed or restarted (same PID, 16h uptime), and the supervisors themselves were still alive. It wasn't only orphaned workers. Their stdout pipe had no reader left in any process.

So the leak can happen without the supervisor dying. Fixes that only stop workers once $$ is gone (e.g. #11235's kill -0 "$parent_pid" loop) wouldn't have cleaned this up. A self-imposed deadline per worker/run (#7598's 30s lifetime, #13239's bounded transfers) or a launcher-PID watch (#8633) would have.

Filed by Claude Opus 5.5 via Claude Code.

khightower93 avatar Oct 18 '26 18:10 khightower93

Rechecked against current quattro (60f5b49) by Claude Opus 5.5, with Codex Medium as a second opinion, after the 4.0.4 report above. bin/omarchy-network-speedtest is unchanged there since July, so the leak described earlier in this thread is still present, and none of the pull requests below has merged.

Supervisor alive with no reader. This was tested on a disposable Omarchy ISO worker: with the script's stdout pipe closed, the script exits within a second and its EXIT trap stops all eight workers, both with SIGPIPE at its default and with SIGPIPE ignored the way systemd sets it for services. Its next rate line goes through awk, the write fails, and set -e ends the script. So a closed pipe alone does not keep a supervisor running, and neither of us could find a mechanism on quattro for the four long-lived supervisors reported above. The point still holds whatever the cause: only a fix that puts a deadline inside the script bounds a supervisor that survives with Quickshell still running.

What each open pull request bounds, read from the diffs:

  • #7598 and #13239 both put a deadline in the script itself: #7598 gives each worker a 30s lifetime and caps every transfer, and #13239 caps the whole run at 8s and every transfer with timeout. These are the only two that bound the case above. Neither bounds the initial api.fast.com request at line 46, which still has no timeout.
  • #9344 keeps both speed-test panels loaded, so dismissal no longer destroys the Process before the EXIT trap finishes. That fixes ordinary dismissal, but it sets no limit on the script.
  • #11235 stops the workers once the supervisor is gone, which covers a SIGKILL of the script but not a supervisor that stays alive.
  • #8633 stops the script when the process that launched it exits. Quickshell did not exit in the case above, so it would not have helped there.

#7598, #9344 and #13239 already close this issue when merged. Choosing between them, or combining #9344 with one of the deadline fixes, is the maintainer's decision. Nothing is needed from reporters. Until then, pkill -f omarchy-network-speedtest stops leftover workers.

omarchybot avatar Oct 18 '26 22:10 omarchybot