Subject: Re: bug#619: elogind crashes with needrestart's defaults

From: Mark Hindley <[email-masked]>
Date: Wed, 20 Oct 2021 16:35:01 +0100

Rena,

Whilst we are waiting for a proper fix for this upstream, does the attached
patch prevent the restart?

Thanks

Mark
From 6a86b28d8e80c3605418b4571dc166324a51fd41 Mon Sep 17 00:00:00 2001
From: Mark Hindley <[email-masked]>
Date: Wed, 20 Oct 2021 16:31:08 +0100
Subject: [PATCH] Prevent restart if session has a tty and DISPLAY is set
 (startx).

Restarting elogind in this situation still crashes the GUI. Work around this
until it is fixed upstream.
---
 debian/elogind.init | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/debian/elogind.init b/debian/elogind.init
index fc3cb24a7..4a718fb2f 100644
--- a/debian/elogind.init
+++ b/debian/elogind.init
@@ -53,12 +53,18 @@ case "$1" in
     ;;
   force-reload|restart)
     log_daemon_msg "Restarting session management daemon" "elogind" || true
-    # Use SIGINT for graceful restart so that existing sessions are not lost.
-    start-stop-daemon --stop --quiet --oknodo --signal INT --retry 30 --pidfile $ELOGIND_PID
-    if start-stop-daemon --start --quiet --oknodo --pidfile $ELOGIND_PID --exec $ELOGIND -- $ELOGIND_OPTS; then
-        log_end_msg 0 || true
+    if loginctl session-status | grep -q tty && [ -n "$DISPLAY" ] ; then
+            # Work around #619
+            log_progress_msg "(Unable to restart from a startx GUI)" || true
+            log_end_msg 1 || true
     else
-        log_end_msg 1 || true
+            # Use SIGINT for graceful restart so that existing sessions are not lost.
+            start-stop-daemon --stop --quiet --oknodo --signal INT --retry 30 --pidfile $ELOGIND_PID
+            if start-stop-daemon --start --quiet --oknodo --pidfile $ELOGIND_PID --exec $ELOGIND -- $ELOGIND_OPTS; then
+                    log_end_msg 0 || true
+            else
+                    log_end_msg 1 || true
+            fi
     fi
     ;;
   try-restart)
-- 
2.20.1