From 5f8eb1cb803e6106f23d32c44dd494ca25a11e2c Mon Sep 17 00:00:00 2001 From: tobtoht Date: Tue, 28 Mar 2023 22:50:56 +0200 Subject: [PATCH] refactor: remove childproc --- CMakeLists.txt | 3 --- src/CMakeLists.txt | 4 ---- src/plugins/xmrig/xmrig.cpp | 2 +- src/plugins/xmrig/xmrig.h | 12 ++---------- src/utils/TorManager.cpp | 2 +- src/utils/TorManager.h | 3 +-- src/utils/childproc.cpp | 16 ---------------- src/utils/childproc.h | 26 -------------------------- 8 files changed, 5 insertions(+), 63 deletions(-) delete mode 100644 src/utils/childproc.cpp delete mode 100644 src/utils/childproc.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d53a57..ac79d6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,9 +39,6 @@ if(DEBUG) set(CMAKE_VERBOSE_MAKEFILE ON) endif() -check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H) -check_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL) - # Monero configuration set(BUILD_GUI_DEPS ON) set(BUILD_64 ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 63a196e..e9c3da3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,10 +195,6 @@ if(STACK_TRACE) target_compile_definitions(feather PRIVATE STACK_TRACE=1) endif() -if(HAVE_SYS_PRCTL_H) - target_compile_definitions(feather PRIVATE HAVE_SYS_PRCTL_H=1) -endif() - if(STATIC) target_compile_definitions(feather PRIVATE STATIC=1) endif() diff --git a/src/plugins/xmrig/xmrig.cpp b/src/plugins/xmrig/xmrig.cpp index 403a2e3..aa19945 100644 --- a/src/plugins/xmrig/xmrig.cpp +++ b/src/plugins/xmrig/xmrig.cpp @@ -11,7 +11,7 @@ XmRig::XmRig(const QString &configDir, QObject *parent) : QObject(parent) - , m_process(new ChildProcess(this)) + , m_process(new QProcess(this)) { m_process->setProcessChannelMode(QProcess::MergedChannels); connect(m_process, &QProcess::readyReadStandardOutput, this, &XmRig::handleProcessOutput); diff --git a/src/plugins/xmrig/xmrig.h b/src/plugins/xmrig/xmrig.h index 9f7b54b..03f182e 100644 --- a/src/plugins/xmrig/xmrig.h +++ b/src/plugins/xmrig/xmrig.h @@ -4,15 +4,7 @@ #ifndef FEATHER_XMRIG_H #define FEATHER_XMRIG_H -#include -#include -#include -#include -#include -#include -#include - -#include "utils/childproc.h" +#include class XmRig : public QObject { @@ -36,7 +28,7 @@ private slots: void handleProcessError(QProcess::ProcessError error); private: - ChildProcess *m_process; + QProcess *m_process; QProcess m_killProcess; bool m_elevated; }; diff --git a/src/utils/TorManager.cpp b/src/utils/TorManager.cpp index 75de7ea..f8b3def 100644 --- a/src/utils/TorManager.cpp +++ b/src/utils/TorManager.cpp @@ -16,7 +16,7 @@ TorManager::TorManager(QObject *parent) : QObject(parent) , m_checkConnectionTimer(new QTimer(this)) - , m_process(new ChildProcess(this)) + , m_process(new QProcess(this)) { connect(m_checkConnectionTimer, &QTimer::timeout, this, &TorManager::checkConnection); diff --git a/src/utils/TorManager.h b/src/utils/TorManager.h index c0d4e30..6afb4be 100644 --- a/src/utils/TorManager.h +++ b/src/utils/TorManager.h @@ -9,7 +9,6 @@ #include #include #include -#include "utils/childproc.h" #include "utils/SemanticVersion.h" class TorManager : public QObject @@ -60,7 +59,7 @@ private: static QPointer m_instance; - ChildProcess *m_process; + QProcess *m_process; int m_restarts = 0; bool m_stopRetries = false; bool m_localTor; diff --git a/src/utils/childproc.cpp b/src/utils/childproc.cpp deleted file mode 100644 index 786c190..0000000 --- a/src/utils/childproc.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2023 The Monero Project - -#include "utils/childproc.h" - -ChildProcess::ChildProcess(QObject* parent) {} -ChildProcess::~ChildProcess() {} - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -void ChildProcess::setupChildProcess() { -#if defined(HAVE_SYS_PRCTL_H) && defined(Q_OS_UNIX) - // https://smackerelofopinion.blogspot.com/2015/11/using-prsetpdeathsig-to-reap-child.html - ::prctl(PR_SET_PDEATHSIG, SIGKILL); -#endif -} -#endif \ No newline at end of file diff --git a/src/utils/childproc.h b/src/utils/childproc.h deleted file mode 100644 index 5c63587..0000000 --- a/src/utils/childproc.h +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2023 The Monero Project - -#ifndef FEATHER_FPROCESS_H -#define FEATHER_FPROCESS_H - -#include - -#if defined(HAVE_SYS_PRCTL_H) && defined(Q_OS_UNIX) -#include -#include -#endif - -class ChildProcess : public QProcess { - Q_OBJECT -public: - explicit ChildProcess(QObject *parent); - ~ChildProcess() override; -protected: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - void setupChildProcess() override; -#endif -}; - - -#endif //FEATHER_FPROCESS_H