fix: kill core orphan on gui death (linux)
This commit is contained in:
parent
23c8496e24
commit
b251c98a4e
1 changed files with 13 additions and 0 deletions
|
|
@ -14,6 +14,11 @@
|
||||||
#include "OSXHelpers.h"
|
#include "OSXHelpers.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
#include <signal.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
@ -203,6 +208,14 @@ void CoreProcess::startForegroundProcess(const QStringList &args)
|
||||||
const auto quoted = makeQuotedArgs(m_appPath, args);
|
const auto quoted = makeQuotedArgs(m_appPath, args);
|
||||||
qInfo("running command: %s", qPrintable(quoted));
|
qInfo("running command: %s", qPrintable(quoted));
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
m_process->setChildProcessModifier([] {
|
||||||
|
// the core process becomes orphaned when the gui process exits abruptly (e.g. with kill -9),
|
||||||
|
// so ensure the os also kills the core when that happens to the gui.
|
||||||
|
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
m_process->start(m_appPath, args);
|
m_process->start(m_appPath, args);
|
||||||
|
|
||||||
if (m_process->waitForStarted()) {
|
if (m_process->waitForStarted()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue