From 2a3bc0797368f09ff7cf44dd0ef4fbdd7d30dc59 Mon Sep 17 00:00:00 2001 From: April & May & June Date: Thu, 15 Jan 2026 08:46:41 +0800 Subject: [PATCH] fix: send SIGTERM to process that does not respond to TerminateSession Some child processes may linger (e.g. gnome-keyring-daemon), kill them to avoid the whole session stuck in closing state. Send SIGKILL directly may make systemd-logind be left in a bad state and cannot handle future login, so send SIGTERM instead. TODO: Find out why --- src/daemon/Auth.cpp | 2 +- src/daemon/Display.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/daemon/Auth.cpp b/src/daemon/Auth.cpp index c91e4f0..f825dfc 100644 --- a/src/daemon/Auth.cpp +++ b/src/daemon/Auth.cpp @@ -251,7 +251,7 @@ namespace DDM { QDBusConnection::systemBus()); auto reply = manager.GetSessionByPID(static_cast(sessionProcessId)); reply.waitForFinished(); - if (reply.error().isValid()) { + if (reply.isError()) { qWarning() << "[Auth] GetSessionByPID:" << reply.error().message(); return -1; } diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp index 809c800..da5d026 100644 --- a/src/daemon/Display.cpp +++ b/src/daemon/Display.cpp @@ -366,6 +366,20 @@ namespace DDM { Logind::managerPath(), QDBusConnection::systemBus()); manager.TerminateSession(QString::number(id)); + QTimer::singleShot(2000, this, [this, id]() { + OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(), + Logind::managerPath(), + QDBusConnection::systemBus()); + // Some child processes may linger + // (e.g. gnome-keyring-daemon), kill them to avoid the + // whole session stuck in closing state. Send SIGKILL + // directly may make systemd-logind be left in a bad state + // and cannot handle future login, so send SIGTERM + // instead. + + // TODO: Find out why + manager.KillSession(QString::number(id), "all", 15); + }); } void Display::unlock(QLocalSocket *socket, const QString &user, const QString &password) {