refactor: remove childproc

This commit is contained in:
tobtoht 2023-03-28 22:50:56 +02:00
parent 0abd323bbb
commit 5f8eb1cb80
8 changed files with 5 additions and 63 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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);

View File

@ -4,15 +4,7 @@
#ifndef FEATHER_XMRIG_H
#define FEATHER_XMRIG_H
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <QRegularExpression>
#include <QtNetwork>
#include <QApplication>
#include <QMainWindow>
#include "utils/childproc.h"
#include <QProcess>
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;
};

View File

@ -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);

View File

@ -9,7 +9,6 @@
#include <iostream>
#include <QRegularExpression>
#include <QtNetwork>
#include "utils/childproc.h"
#include "utils/SemanticVersion.h"
class TorManager : public QObject
@ -60,7 +59,7 @@ private:
static QPointer<TorManager> m_instance;
ChildProcess *m_process;
QProcess *m_process;
int m_restarts = 0;
bool m_stopRetries = false;
bool m_localTor;

View File

@ -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

View File

@ -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 <QProcess>
#if defined(HAVE_SYS_PRCTL_H) && defined(Q_OS_UNIX)
#include <signal.h>
#include <sys/prctl.h>
#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