Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 930154
Collapse All | Expand All

(-)a/src/gui/systemd/scopedprocessrunner.cpp (-23 / +3 lines)
Lines 3-10 Link Here
3
#include "scopedprocessrunner_p.h"
3
#include "scopedprocessrunner_p.h"
4
#include "systemdprocessrunner_p.h"
4
#include "systemdprocessrunner_p.h"
5
5
6
#include <sys/eventfd.h>
7
8
using namespace org::freedesktop;
6
using namespace org::freedesktop;
9
7
10
ScopedProcessRunner::ScopedProcessRunner()
8
ScopedProcessRunner::ScopedProcessRunner()
Lines 12-34 ScopedProcessRunner::ScopedProcessRunner() Link Here
12
{
10
{
13
}
11
}
14
12
15
void ScopedProcessRunner::startProcess()
13
void ScopedProcessRunner::slotProcessStarted()
16
{
14
{
17
    std::function oldModifier = m_process->childProcessModifier();
15
    ForkingProcessRunner::slotProcessStarted();
18
    int efd = eventfd(0, EFD_CLOEXEC);
19
    m_process->setChildProcessModifier([efd, oldModifier]() {
20
        // wait for the parent process to be done registering the transient unit
21
        eventfd_read(efd, nullptr);
22
        if (oldModifier)
23
            oldModifier();
24
    });
25
26
    // actually start
27
    ForkingProcessRunner::startProcess();
28
    m_process->setChildProcessModifier(oldModifier);
29
30
    Q_ASSERT(m_process->processId());
31
32
    // As specified in "XDG standardization for applications" in https://systemd.io/DESKTOP_ENVIRONMENTS/
16
    // As specified in "XDG standardization for applications" in https://systemd.io/DESKTOP_ENVIRONMENTS/
33
    const QString serviceName = QStringLiteral("app-%1-%2.scope").arg(escapeUnitName(resolveServiceAlias()), QUuid::createUuid().toString(QUuid::Id128));
17
    const QString serviceName = QStringLiteral("app-%1-%2.scope").arg(escapeUnitName(resolveServiceAlias()), QUuid::createUuid().toString(QUuid::Id128));
34
18
Lines 46-52 void ScopedProcessRunner::startProcess() Link Here
46
                                    {} // aux is currently unused and should be passed as empty array.
30
                                    {} // aux is currently unused and should be passed as empty array.
47
        );
31
        );
48
32
49
    connect(new QDBusPendingCallWatcher(startReply, this), &QDBusPendingCallWatcher::finished, [serviceName, efd](QDBusPendingCallWatcher *watcher) {
33
    connect(new QDBusPendingCallWatcher(startReply, this), &QDBusPendingCallWatcher::finished, [serviceName](QDBusPendingCallWatcher *watcher) {
50
        QDBusPendingReply<QDBusObjectPath> reply = *watcher;
34
        QDBusPendingReply<QDBusObjectPath> reply = *watcher;
51
        watcher->deleteLater();
35
        watcher->deleteLater();
52
        if (reply.isError()) {
36
        if (reply.isError()) {
Lines 54-63 void ScopedProcessRunner::startProcess() Link Here
54
        } else {
38
        } else {
55
            qCDebug(KIO_GUI) << "Successfully registered new cgroup:" << serviceName;
39
            qCDebug(KIO_GUI) << "Successfully registered new cgroup:" << serviceName;
56
        }
40
        }
57
58
        // release child and close the eventfd
59
        eventfd_write(efd, 1);
60
        close(efd);
61
    });
41
    });
62
}
42
}
63
43
(-)a/src/gui/systemd/scopedprocessrunner_p.h (-2 / +2 lines)
Lines 7-13 class ScopedProcessRunner : public ForkingProcessRunner Link Here
7
    Q_OBJECT
7
    Q_OBJECT
8
public:
8
public:
9
    explicit ScopedProcessRunner();
9
    explicit ScopedProcessRunner();
10
    void startProcess() override;
10
private Q_SLOTS:
11
    void slotProcessStarted() override;
11
};
12
};
12
13
13
#endif // SCOPEDPROCESSRUNNER_H
14
#endif // SCOPEDPROCESSRUNNER_H
14
- 

Return to bug 930154