Skip to content

Cap fprintd's stop timeout so the resume hook cannot stall the thaw - #1

Closed
MaxMad75 wants to merge 1 commit into
GeertJohan:lock-fingerprint-recoveryfrom
MaxMad75:fprintd-stop-timeout
Closed

MaxMad75 wants to merge 1 commit into
GeertJohan:lock-fingerprint-recoveryfrom
MaxMad75:fprintd-stop-timeout

Conversation

@MaxMad75

Copy link
Copy Markdown

Four lines and a drop-in, offered against your branch rather than as a fifth PR in this area — it only has value once a resume mechanism lands, and yours is the one I would like to see land.

Why

Your hook restarts fprintd synchronously, while user.slice is still frozen, so whatever the stop costs is added to the thaw. The hook's comment says a wedged fprintd "is idle and exits on SIGTERM in milliseconds". For the wedge this PR targets that is exactly right — I held the reader with fprintd-verify and restarted:

20:14:01.452  Stopping Fingerprint Authentication Daemon...
20:14:01.454  fprintd.service: Deactivated successfully      ← 2 ms
20:14:01.791  Started Fingerprint Authentication Daemon      ← 340 ms total

But there is a second wedge — the stale device handle after a USB re-enumeration (omacom#8818, and the one I closed omacom#8935 over). That instance does not answer SIGTERM. Two of the ten fprintd stops in this machine's journal are it:

Aug 28 17:16:19.233  Stopping Fingerprint Authentication Daemon...
Aug 28 17:16:24.308  fprintd.service: State 'stop-sigterm' timed out. Killing.
Aug 28 17:16:24.308  Killing process 24160 (fprintd) with signal SIGKILL
Aug 28 17:16:24.314  Stopped                                  ← 5.08 s
                     Consumed 1.183s CPU over 3h 57min wall clock

The second, at 10:10:15, is 5.02 s — both are DefaultTimeoutStopSec=5s from etc/systemd/system.conf.d/10-faster-shutdown.conf running out. So resume goes from ~0.5 s to ~5.6 s, and it does so precisely when the daemon is wedged, which is the case the hook exists for. timeout 10s does not bound it: it sits above the 5 s, and as your own comment notes, killing the client leaves the job enqueued regardless.

TimeoutStopSec=3s is well clear of a healthy stop (2 ms measured, 340 ms for the whole restart) and still leaves your 10 s bound room for the start that follows.

What this changes

The cap travels with the hook everywhere the hook goes — setup, omarchy-apply-lock, the migration, and removal — for the reason your own comment in omarchy-apply-lock gives about the hook and the PAM file: the pair is only correct together. Each is daemon-reloaded after, since a drop-in nobody reloads is a drop-in that does nothing.

The migration's guard is restructured so each half is checked on its own. Without that, a machine that took the hook on an earlier run would hit ! -e $hook_dst and exit before ever seeing the cap.

Tests

test/shell.d/fprintd-resume-migration-test.sh goes from 4 to 7 assertions: the cap installs from the default source at 0644 and reloads systemd, an existing cap is left alone and reloads nothing, and a machine that already has the hook still gets the cap. All four mutations I tried are caught — dropping the daemon-reload, dropping the install, installing 0755, and removing the ! -e guard.

Green here: fprintd-resume-migration (7), fprintd-resume-hook (4), lock-fingerprint-retry (28), sleep-lock (19). unowned-system-paths fails on this machine for want of an omarchy-pkgs checkout, unrelated — and the new file lands in /etc, which that test explicitly treats as administrator territory.

Verified on hardware

ThinkPad X390 Yoga, Synaptics 06cb:00bd, mem_sleep=deep (S3), fprintd 1.94.5-2, libfprint 1.94.100-1, systemd 261, Omarchy 4.0.1.

$ systemctl show fprintd -p TimeoutStopUSec --value
3s

Your hook itself, tested verbatim on the same machine, is in my comment on omacom#7158 — 9 ms to fire, 455 ms to a fresh daemon, ordered before the lock screen's own resume work.

Take it, rework it, or tell me to drop it — whichever suits the PR best.

The hook restarts fprintd synchronously, while user sessions are still
frozen, so whatever the stop costs is added to the thaw. A healthy
daemon stops in about 2ms even while holding a claim, but a wedged one
does not answer SIGTERM and has to be killed: 5.08s and 5.02s in this
machine's journal, against Omarchy's DefaultTimeoutStopSec=5s. That is
the case the hook exists for, so uncapped the recovery costs more than
the failure it repairs. The hook's 10s bound does not help -- it sits
above the 5s, and killing the client leaves the job enqueued anyway.

The cap travels with the hook through setup, apply-lock, the migration
and removal, for the same reason the hook travels with the PAM file:
the pair is only correct together.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018eDjGAT4r43qvHmB58y2tz
@GeertJohan

Copy link
Copy Markdown
Owner

Thanks — the cap landed on the branch as d58aa12, with you as co-author, and I took your rmdir on removal. Two things differ from #1 that you'll want to know about:

  1. The hook went asynchronous (systemctl --no-block try-restart) in the same commit. user.slice is only thawed after the post hooks return (systemd 261 sleep.c), so a synchronous restart means a black, unresponsive screen for the whole stop+start — 3 s with your cap, up to the old timeout 10s if the start never reaches its bus name. Off the thaw, the lock loop absorbs the restart landing under its first attempt. Since you're the one with S3 hardware that freezes sessions, a run of the async variant would be very welcome.
  2. omarchy-apply-lock's removal branch runs in the ISO chroot (via install/config/lockscreen-pam.sh), where systemctl daemon-reload fails and would abort the install under set -e, so the reload there is guarded on the drop-in actually existing.

Closing this in favour of the branch commit.

@GeertJohan GeertJohan closed this Aug 29, 2026
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