From 3b00cd06f82837ba85f37c9f632261e7b4c6fd35 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Wed, 9 Dec 2020 19:28:41 +0100 Subject: [PATCH] Explicitly stop Xorg when starting fails When Xorg starts but there is an error, stop it explicitly instead of assuming that X exits itself. This avoids a possibly lingering Xorg process in the XorgDisplayServer instance. Add a check and warning message if Xorg is restarted too early (shouldn't happen). --- src/daemon/XorgDisplayServer.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp index 5f40fe8c3..3a7bee0d8 100644 --- a/src/daemon/XorgDisplayServer.cpp +++ b/src/daemon/XorgDisplayServer.cpp @@ -118,6 +118,11 @@ namespace SDDM { if (m_started) return false; + if (process) { + qCritical() << "Tried to start Xorg before previous instance exited"; + return false; + } + // create process process = new QProcess(this); @@ -195,6 +200,7 @@ namespace SDDM { qCritical("Failed to open pipe to start X Server"); close(pipeFds[0]); + stop(); return false; } QByteArray displayNumber = readPipe.readLine(); @@ -203,6 +209,7 @@ namespace SDDM { qCritical("Failed to read display number from pipe"); close(pipeFds[0]); + stop(); return false; } displayNumber.prepend(QByteArray(":")); @@ -219,6 +226,7 @@ namespace SDDM { if(m_display != QStringLiteral(":0")) { if(!addCookie(m_authPath)) { qCritical() << "Failed to write xauth file"; + stop(); return false; } } @@ -232,8 +240,7 @@ namespace SDDM { } void XorgDisplayServer::stop() { - // check flag - if (!m_started) + if (!process) return; // log message