File create_pid_file.patch of Package sddm

diff --git a/src/common/Constants.h.in b/src/common/Constants.h.in
index b32b2e07687aecc545d18f47c28bb650a308e758..2be895e730da5affb2cd4f6052918a8ab4b2672a 100644
--- a/src/common/Constants.h.in
+++ b/src/common/Constants.h.in
@@ -34,6 +34,7 @@
 
 #define CONFIG_FILE                 "@CONFIG_FILE@"
 #define LOG_FILE                    "@LOG_FILE@"
+#define PID_FILE                    "@PID_FILE@"
 #define MINIMUM_VT                  @MINIMUM_VT@
 
 #define UID_MIN                     @UID_MIN@
diff --git a/src/daemon/DaemonApp.cpp b/src/daemon/DaemonApp.cpp
index ae8ae3b..ea2d0be 100644
--- a/src/daemon/DaemonApp.cpp
+++ b/src/daemon/DaemonApp.cpp
@@ -31,6 +31,7 @@
 #include <QDebug>
 #include <QHostInfo>
 #include <QTimer>
+#include <QFile>
 
 #include <iostream>
 
@@ -46,6 +47,15 @@ namespace SDDM {
         // log message
         qDebug() << "Initializing...";
 
+        // Write PID File
+        if ( ! QString(QStringLiteral(PID_FILE)).isEmpty() ) {
+            QFile pidFile(QStringLiteral(PID_FILE));
+            QString pid = QString::number(QCoreApplication::applicationPid());
+            if ( pidFile.open(QIODevice::WriteOnly | QIODevice::Text) ) {
+                pidFile.write(pid.toLatin1().data(), qstrlen(pid.toLatin1().data()));
+                pidFile.close();
+            }
+        }
         // set testing parameter
         m_testing = (arguments().indexOf(QStringLiteral("--test-mode")) != -1);
 
openSUSE Build Service is sponsored by