Repository navigation
Prevent lid closure from interrupting shutdown - #13076
Conversation
Automated AI review
Verified: the change addresses the reported problem. With the
Verified from systemd v261.3 source:
Shutdown is silently dropped if a lid suspend wins the lock-acquisition race
(Source trace through Impact: low likelihood, but a confusing result when it occurs. The window covers process start, a bus connection and the polkit checks. That is an estimated milliseconds to tens of milliseconds on an idle system, usually shorter than the time needed to close a lid after choosing Shut Down, but it is not bounded under load. Inside that window, the base still queued a power-off attempt and closed windows. This PR instead leaves the session untouched with no user-visible sign that shutdown failed. The same silent path applies whenever Suggested change: do not let an inhibitor failure end the shutdown silently. Optional approaches:
Optional test improvement: Review informationTest scope: The review covered source for both changed files, their callers and helpers, and the relevant systemd v261.3 logind, AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, with follow-up source checks on the lock-acquisition race, and an Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
Automated AI review
Follow-up to the earlier review and the author's reply, checked at Verified: both earlier points are resolved. One new low-likelihood robustness point is noted below.
Verified for the notification path:
Author claims:
Worker path now comes from the service environmentAt the earlier head, the caller's shell expanded
Impact: low likelihood, from source and a stubbed emulation, not reproduced on a real system. In that window, Shut Down runs one copy's wrapper and another copy's worker. If the other copy has been removed, Suggested change: use Optional notes:
Review informationTest scope: Source review of both changed files at AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical follow-up review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
Automated AI review
Follow-up to the earlier follow-up review and the author's reply, checked at Verified: the worker-path point is resolved. No regressions were found in the new commit.
Verified for the new commit:
Author claims: all confirmed.
Optional notes:
Review informationTest scope: Source review of the AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical follow-up review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
Reviewed at Reproduction. I used a disposable Omarchy worker VM running systemd 261, with a uinput lid switch, logind set to suspend on lid close, and Tests. I ran Second opinion. Codex at medium effort also reviewed this and found the change proportionate, with no privilege change and no broken caller. It raised the same point as the community review's optional note: if Worth knowing, not blocking:
This now waits on the maintainer. |
Prevent lid closure from interrupting shutdown (cherry picked from commit 58aa857)
Problem
Choosing Shut Down and closing the lid can suspend the laptop instead of shutting it down. Reopening the lid resumes the session. See #4273.
Fix
Add
sleep:idle:handle-lid-switchinhibition through shutdown preparation, the two-second delay, and the power-off request. The lid-specific lock is needed because ordinary sleep inhibitors do not normally block lid-triggered suspend.Start the user service immediately and move the delay inside it. Run preparation in the background and add a 30-second runtime limit to initiate cleanup if the worker stalls.
Show a critical notification if inhibitor acquisition or the power-off request fails, while preserving the failure status.
Testing