KIO
systemdprocessrunner.cpp
26 // overrides for unit test purposes. These are considered internal, private and may change in the future.
38 auto queryVersionMessage = QDBusMessage::createMethodCall(systemdService, systemdPath, u"org.freedesktop.DBus.Properties"_s, u"Get"_s);
43 qCWarning(KIO_GUI) << "Failed to determine systemd version, falling back to extremely legacy forking mode.";
46 if (systemdVersion.majorVersion() < 250) { // first version with ExitType=cgroup, which won't cleanup when the first process exits
93 QProcessEnvironment allowedEnvironment = environment.inheritsFromParent() ? QProcessEnvironment::systemEnvironment() : environment;
99 qCWarning(KIO_GUI) << "Not passing environment variable" << variable << "to systemd because its name contains illegal characters";
119 // As specified in "XDG standardization for applications" in https://systemd.io/DESKTOP_ENVIRONMENTS/
120 m_serviceName = QStringLiteral("app-%1@%2.service").arg(escapeUnitName(resolveServiceAlias()), QUuid::createUuid().toString(QUuid::Id128));
123 m_manager = new systemd1::Manager(systemdService, systemdPath, QDBusConnection::sessionBus(), this);
131 [this](uint jobId, const QDBusObjectPath &jobPath, const QString &unitName, const QString &result) {
133 if (jobPath.path() == m_jobPath && unitName == m_serviceName && result != QLatin1String("done")) {
134 qCWarning(KIO_GUI) << "Failed to launch process as service:" << m_serviceName << ", result " << result;
147 QStringLiteral("fail"), // mode defines what to do in the case of a name conflict, in this case, just do nothing
155 {QStringLiteral("AddRef"), true}, // Asks systemd to avoid garbage collecting the service if it immediately crashes,
159 {QStringLiteral("ExecStart"), QVariant::fromValue(ExecCommandList{{m_process->program().first(), argv, false}})},
163 connect(new QDBusPendingCallWatcher(startReply, this), &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
167 qCWarning(KIO_GUI) << "Failed to launch process as service:" << m_serviceName << reply.error().name() << reply.error().message();
170 qCDebug(KIO_GUI) << "Successfully asked systemd to launch process as service:" << m_serviceName;
180 qCWarning(KIO_GUI) << "Failed to get properties for service:" << m_serviceName << reply.error().name() << reply.error().message();
200 // ExecMainStatus is the process exit code in case of normal exit, otherwise it is the signal number
202 const auto exitCodeOrSignalNumber = properties[QStringLiteral("ExecMainStatus")].value<qint32>();
203 const auto exitStatus = signalCode == CLD_EXITED ? QProcess::ExitStatus::NormalExit : QProcess::ExitStatus::CrashExit;
205 qCDebug(KIO_GUI) << m_serviceName << "pid=" << m_pid << "exitCode=" << exitCodeOrSignalNumber << "exitStatus=" << exitStatus;
209 systemd1::Unit unitInterface(systemdService, m_servicePath, QDBusConnection::sessionBus(), this);
210 connect(new QDBusPendingCallWatcher(unitInterface.Unref(), this), &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
214 qCWarning(KIO_GUI) << "Failed to unref service:" << m_serviceName << reply.error().name() << reply.error().message();
230 m_serviceProperties = new DBus::Properties(systemdService, m_servicePath, QDBusConnection::sessionBus(), this);
232 connect(new QDBusPendingCallWatcher(propReply, this), &QDBusPendingCallWatcher::finished, this, &SystemdProcessRunner::handleProperties);
242 connect(new QDBusPendingCallWatcher(reply, this), &QDBusPendingCallWatcher::finished, this, &SystemdProcessRunner::handleProperties);
char * toString(const EngineQuery &query)
QString path(const QString &relativePath)
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
KGuiItem properties()
QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode, int timeout) const const
QDBusConnection sessionBus()
QString message() const const
QString name() const const
QDBusMessage createMethodCall(const QString &service, const QString &path, const QString &interface, const QString &method)
QString path() const const
void finished(QDBusPendingCallWatcher *self)
QVariant argumentAt(int index) const const
QDBusError error() const const
bool isError() const const
int exec(ProcessEventsFlags flags)
void quit()
iterator begin()
iterator end()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
bool inheritsFromParent() const const
QStringList keys() const const
void remove(const QString &name)
QProcessEnvironment systemEnvironment()
QStringList toStringList() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
singleShot
Id128
QUuid createUuid()
QVariant fromValue(T &&value)
QVersionNumber fromString(QAnyStringView string, qsizetype *suffixIndex)
bool isNull() const const
int majorVersion() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.