Fix I2P child-process bug
This commit is contained in:
parent
e5740c383f
commit
42f9643874
@ -2,9 +2,15 @@
|
|||||||
#include "prog-constains.h"
|
#include "prog-constains.h"
|
||||||
#include "locales.h"
|
#include "locales.h"
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX)
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
I2PController::I2PController(QObject *parent)
|
I2PController::I2PController(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
i2p.setWorkingDirectory(I2P_INSTALL_PATH);
|
||||||
this->isFatalErrored = false;
|
this->isFatalErrored = false;
|
||||||
|
|
||||||
connect(&i2p, &QProcess::errorOccurred,
|
connect(&i2p, &QProcess::errorOccurred,
|
||||||
@ -14,7 +20,8 @@ I2PController::I2PController(QObject *parent)
|
|||||||
this, &I2PController::onProcessFinished);
|
this, &I2PController::onProcessFinished);
|
||||||
|
|
||||||
connect(&i2p, &QProcess::readyReadStandardOutput, this, [this]() {
|
connect(&i2p, &QProcess::readyReadStandardOutput, this, [this]() {
|
||||||
qDebug() << "[i2pd]" << i2p.readAllStandardOutput();
|
// Logging I2P
|
||||||
|
//qDebug() << "[i2pd]" << i2p.readAllStandardOutput();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&i2p, &QProcess::readyReadStandardError, this, [this]() {
|
connect(&i2p, &QProcess::readyReadStandardError, this, [this]() {
|
||||||
@ -42,6 +49,18 @@ I2PController::I2PController(QObject *parent)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
I2PController::~I2PController()
|
||||||
|
{
|
||||||
|
if (i2p.state() != QProcess::NotRunning)
|
||||||
|
{
|
||||||
|
i2p.terminate();
|
||||||
|
i2p.waitForFinished(3000);
|
||||||
|
|
||||||
|
if (i2p.state() != QProcess::NotRunning)
|
||||||
|
i2p.kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void I2PController::start() {
|
void I2PController::start() {
|
||||||
if (i2p.state() != QProcess::NotRunning)
|
if (i2p.state() != QProcess::NotRunning)
|
||||||
{
|
{
|
||||||
@ -49,6 +68,13 @@ void I2PController::start() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX)
|
||||||
|
// If SIGKILL on Linux
|
||||||
|
i2p.setChildProcessModifier([]() {
|
||||||
|
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
this->i2p.start(QDir(I2P_INSTALL_PATH).filePath("i2pd.exe"), args);
|
this->i2p.start(QDir(I2P_INSTALL_PATH).filePath("i2pd.exe"), args);
|
||||||
@ -61,6 +87,7 @@ void I2PController::start() {
|
|||||||
<< "--tunconf" << QDir(configsFolder).filePath("tunnels.conf")
|
<< "--tunconf" << QDir(configsFolder).filePath("tunnels.conf")
|
||||||
<< "--log" << QDir(logsFolder).filePath("i2pd.log");
|
<< "--log" << QDir(logsFolder).filePath("i2pd.log");
|
||||||
|
|
||||||
|
//qDebug() << "i2pd args:" << args;
|
||||||
this->i2p.start(QDir(I2P_INSTALL_PATH).filePath("i2pd"), args);
|
this->i2p.start(QDir(I2P_INSTALL_PATH).filePath("i2pd"), args);
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class I2PController : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
I2PController(QObject *parent = nullptr);
|
I2PController(QObject *parent = nullptr);
|
||||||
|
~I2PController();
|
||||||
void start();
|
void start();
|
||||||
private:
|
private:
|
||||||
QProcess i2p;
|
QProcess i2p;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user