kded: refuse to start if service is already registered

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-05-22 04:34:18 +03:00
parent 926345627a
commit d9281db1f8

View file

@ -40,6 +40,8 @@
#include <QProcess>
#include <QHostInfo>
#include <QDBusReply>
#include <QDBusConnectionInterface>
#include <unistd.h>
#include <stdlib.h>
@ -665,6 +667,17 @@ int main(int argc, char *argv[])
KDE_signal(SIGTERM, sighandler);
KDE_signal(SIGHUP, sighandler);
QDBusConnection session = QDBusConnection::sessionBus();
if (!session.isConnected()) {
kWarning() << "No DBUS session-bus found. Check if you have started the DBUS server.";
return 1;
}
QDBusReply<bool> sessionReply = session.interface()->isServiceRegistered("org.kde.kded");
if (sessionReply.isValid() && sessionReply.value() == true) {
kWarning() << "Another instance of kded4 is already running!";
return 2;
}
KConfigGroup cg(config, "General");
HostnamePollInterval = cg.readEntry("HostnamePollInterval", 5000);
bCheckSycoca = cg.readEntry("CheckSycoca", true);