From bf6ee5e65f122076caa6a2a3773bdc0283f1db83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Negrier=20Duarte?= Date: Wed, 17 Apr 2024 18:21:34 +0100 Subject: [PATCH] Revert "Make ScopedProcessRunner hold the child until we register with systemd" This reverts commit 152fa94b5fb2c3226b0f8f7975c1f06bec4ecdaa. --- src/gui/systemd/scopedprocessrunner.cpp | 26 +++---------------------- src/gui/systemd/scopedprocessrunner_p.h | 3 ++- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/gui/systemd/scopedprocessrunner.cpp b/src/gui/systemd/scopedprocessrunner.cpp index d9b165534..ff95e41b2 100644 --- a/src/gui/systemd/scopedprocessrunner.cpp +++ b/src/gui/systemd/scopedprocessrunner.cpp @@ -3,8 +3,6 @@ #include "scopedprocessrunner_p.h" #include "systemdprocessrunner_p.h" -#include - using namespace org::freedesktop; ScopedProcessRunner::ScopedProcessRunner() @@ -12,23 +10,9 @@ ScopedProcessRunner::ScopedProcessRunner() { } -void ScopedProcessRunner::startProcess() +void ScopedProcessRunner::slotProcessStarted() { - std::function oldModifier = m_process->childProcessModifier(); - int efd = eventfd(0, EFD_CLOEXEC); - m_process->setChildProcessModifier([efd, oldModifier]() { - // wait for the parent process to be done registering the transient unit - eventfd_read(efd, nullptr); - if (oldModifier) - oldModifier(); - }); - - // actually start - ForkingProcessRunner::startProcess(); - m_process->setChildProcessModifier(oldModifier); - - Q_ASSERT(m_process->processId()); - + ForkingProcessRunner::slotProcessStarted(); // As specified in "XDG standardization for applications" in https://systemd.io/DESKTOP_ENVIRONMENTS/ const QString serviceName = QStringLiteral("app-%1-%2.scope").arg(escapeUnitName(resolveServiceAlias()), QUuid::createUuid().toString(QUuid::Id128)); @@ -46,7 +30,7 @@ void ScopedProcessRunner::startProcess() {} // aux is currently unused and should be passed as empty array. ); - connect(new QDBusPendingCallWatcher(startReply, this), &QDBusPendingCallWatcher::finished, [serviceName, efd](QDBusPendingCallWatcher *watcher) { + connect(new QDBusPendingCallWatcher(startReply, this), &QDBusPendingCallWatcher::finished, [serviceName](QDBusPendingCallWatcher *watcher) { QDBusPendingReply reply = *watcher; watcher->deleteLater(); if (reply.isError()) { @@ -54,10 +38,6 @@ void ScopedProcessRunner::startProcess() } else { qCDebug(KIO_GUI) << "Successfully registered new cgroup:" << serviceName; } - - // release child and close the eventfd - eventfd_write(efd, 1); - close(efd); }); } diff --git a/src/gui/systemd/scopedprocessrunner_p.h b/src/gui/systemd/scopedprocessrunner_p.h index eae39edcc..c7498ed3f 100644 --- a/src/gui/systemd/scopedprocessrunner_p.h +++ b/src/gui/systemd/scopedprocessrunner_p.h @@ -7,7 +7,8 @@ class ScopedProcessRunner : public ForkingProcessRunner Q_OBJECT public: explicit ScopedProcessRunner(); - void startProcess() override; +private Q_SLOTS: + void slotProcessStarted() override; }; #endif // SCOPEDPROCESSRUNNER_H -- 2.44.0