Skip to content

csm-systemd: wait for logind's PrepareForShutdown before quitting - #215

Open
leigh123linux wants to merge 1 commit into
linuxmint:masterfrom
leigh123linux:systemd_shutdown_issue
Open

csm-systemd: wait for logind's PrepareForShutdown before quitting#215
leigh123linux wants to merge 1 commit into
linuxmint:masterfrom
leigh123linux:systemd_shutdown_issue

Conversation

@leigh123linux

Copy link
Copy Markdown
Member

cinnamon-session quit immediately after requesting PowerOff/Reboot via
logind, without confirming logind had actually accepted the request. If
another process held a delay inhibitor, cinnamon-session would tear
down and hand back to the display manager greeter well before the
machine actually powered off, leaving the session in a misleading
half-terminated state for the duration of the delay.

Take our own delay inhibitor before requesting shutdown/restart, drop
any held block inhibitor (which would make logind refuse the request
outright), and wait for logind's PrepareForShutdown signal to confirm
shutdown is genuinely proceeding before quitting -- matching
gnome-session's gsm_systemd_prepare_shutdown()/complete_shutdown().

Also remove the MDM display-manager fallback path (quit_request_failed,
mdm_set_logout_action calls, the CSM_MANAGER_LOGOUT_*_MDM enum values,
and mdm.c/mdm.h) since it's dead: Linux Mint dropped MDM for LightDM
years ago, and the fallback was never actually reachable once
csm_manager_quit() started quitting unconditionally after issuing the
shutdown/restart request.

Fixes: #214

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are confirmed failure-path issues that can crash initialization or leave the session stuck in a non-running phase when shutdown/reboot isn’t confirmed.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves cinnamon-session’s shutdown/reboot flow when using logind by taking its own delay inhibitor, dropping conflicting block inhibitors, and waiting for logind’s PrepareForShutdown signal before quitting; it also removes the long-dead MDM display-manager fallback code paths.

Changes:

  • Add a shutdown-prepared signal and complete_shutdown() hook to the CsmSystem interface, and implement delay-inhibitor handling + PrepareForShutdown listening in the systemd backend.
  • Update CsmManager to quit only after shutdown is confirmed (and remove the old request-failed → MDM fallback).
  • Remove mdm.c/mdm.h and update the build to stop compiling MDM logout-action support.
File summaries
File Description
cinnamon-session/meson.build Removes mdm.c from the build sources.
cinnamon-session/mdm.h Deletes legacy MDM logout-action API header.
cinnamon-session/mdm.c Deletes legacy MDM protocol implementation.
cinnamon-session/csm-systemd.c Adds delay inhibitor + waits for PrepareForShutdown, emits shutdown-prepared, implements complete_shutdown().
cinnamon-session/csm-system.h Extends CsmSystemInterface with complete_shutdown().
cinnamon-session/csm-system.c Adds shutdown-prepared signal and csm_system_complete_shutdown() wrapper.
cinnamon-session/csm-manager.c Removes MDM fallback and waits for shutdown-prepared before quitting.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +470 to +474
on_shutdown_prepared (CsmSystem *system,
gboolean success,
gpointer user_data)
{
g_warning ("Using an MDM logout action to shutdown/reboot the system.");
MdmLogoutAction fallback_action = GPOINTER_TO_INT (user_data);
mdm_set_logout_action (fallback_action);
csm_quit ();
g_signal_handlers_disconnect_by_func (system, on_shutdown_prepared, user_data);
Comment on lines +158 to 162
} else {
g_signal_connect (manager->priv->sd_proxy, "g-signal",
G_CALLBACK (sd_proxy_signal_cb), manager);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants