Skip to content

Session is not closed when shutdown starts while another process holds a delay inhibitor #214

Description

@Fantu

Still reproducible on current master (d10f424, 6.7.4-unstable).

Problem

When the user asks for shutdown or reboot, cinnamon-session runs its end-session phases and then calls logind PowerOff(), but it never terminates itself. If any other process holds a delay shutdown inhibitor, logind postpones the transition and the session stays on screen in a half-terminated state: it is already past the RUNNING phase, so the panel's next org.gnome.SessionManager.Shutdown call fails with

GDBus.Error:org.gnome.SessionManager.NotInRunning: Shutdown interface is only available during the Running phase

the desktop icons are gone because the apps were already asked to end, and yet applications can still be launched. The machine only powers off when the other inhibitor is released.

The original report comes from a unattended-upgrades setup with InstallOnShutdown "true" and InhibitDelayMaxSec=1800, but any long delay inhibitor triggers it. With the default InhibitDelayMaxSec of a few seconds nobody notices.

How to reproduce

systemd-inhibit --what=shutdown --mode=delay --who=test --why=test sleep 300

then shut down from the Cinnamon menu: the session stays visible and usable for the whole delay.

Where it comes from

csm_manager_quit() (cinnamon-session/csm-manager.c:487) exits the session for logout, but not for shutdown/reboot:

case CSM_MANAGER_LOGOUT_LOGOUT:
        csm_quit ();
        break;
...
case CSM_MANAGER_LOGOUT_SHUTDOWN:
case CSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
        csm_system_attempt_stop (manager->priv->system);   /* line 520, no csm_quit() */
        break;

csm_systemd_attempt_stop() (csm-systemd.c:236) just calls PowerOff(TRUE) and relies on systemd to tear everything down. cinnamon-session also never takes a delay inhibitor of its own: csm_systemd_add_inhibitor() only ever takes block ones on behalf of session apps (csm-systemd.c:629).

gnome-session handles this differently: gsm_systemd_prepare_shutdown() takes its own delay inhibitor before calling PowerOff/Reboot, and gsm_manager_quit() then calls gsm_system_complete_shutdown() (which drops that inhibitor) followed by gsm_quit(). The session goes away in any case, and the shutdown proceeds once the remaining inhibitors allow it.

Suggested fix

Port that split rather than simply adding a csm_quit() after csm_system_attempt_stop() — the PowerOff call is asynchronous, so quitting right after it would cut it short. That is: take a delay inhibitor before requesting PowerOff/Reboot, release it at quit time, and let the session exit.

Related reports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions