diff options
author | Samuli Piippo <samuli.piippo@digia.com> | 2014-09-02 10:29:56 +0300 |
---|---|---|
committer | Samuli Piippo <samuli.piippo@digia.com> | 2014-09-02 10:30:17 +0300 |
commit | 22d4670b58dcb64a47ee589fbe922cb30a3e506c (patch) | |
tree | 2ec6c8e09e362dd2a179db75985288b4e9d2efd4 | |
parent | 7e3f7fab8ed8a7c79e4e136c4abbc1887a5f3152 (diff) | |
parent | 224cdd83d41d659ec166f7177a549d391ed1d5cc (diff) |
Merge remote-tracking branch 'origin/stable' into dev
* origin/stable:
Always create a process group and session
Use compile time connections
Print crashed application binary
Change-Id: I230d54c029ac881c1661009c52f44c4e0b148022
-rw-r--r-- | main.cpp | 4 | ||||
-rw-r--r-- | process.cpp | 20 |
2 files changed, 13 insertions, 11 deletions
@@ -230,6 +230,8 @@ int main(int argc, char **argv) return 1; } + ::setpgid(0,0); // must be called before setsid() + ::setsid(); Config config = parseConfigFile(); while (!args.isEmpty()) { @@ -247,8 +249,6 @@ int main(int argc, char **argv) } } else if (arg == "--debug-gdb") { useGDB = true; - setpgid(0,0); // must be called before setsid() - setsid(); } else if (arg == "--debug-qml") { useQML = true; } else if (arg == "--stop") { diff --git a/process.cpp b/process.cpp index 6321c87..0584ccf 100644 --- a/process.cpp +++ b/process.cpp @@ -88,11 +88,11 @@ Process::Process() , mDebug(false) { mProcess->setProcessChannelMode(QProcess::SeparateChannels); - connect(mProcess, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError())); - connect(mProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput())); - connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus))); - connect(mProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError))); - connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)), qApp, SLOT(quit())); + connect(mProcess, &QProcess::readyReadStandardError, this, &Process::readyReadStandardError); + connect(mProcess, &QProcess::readyReadStandardOutput, this, &Process::readyReadStandardOutput); + connect(mProcess, (void (QProcess::*)(int, QProcess::ExitStatus))&QProcess::finished, this, &Process::finished); + connect(mProcess, (void (QProcess::*)(QProcess::ProcessError))&QProcess::error, this, &Process::error); + connect(mProcess, (void (QProcess::*)(int, QProcess::ExitStatus))&QProcess::finished, qApp, &QCoreApplication::quit); if (pipe2(pipefd, O_CLOEXEC) != 0) qWarning("Could not create pipe"); @@ -150,7 +150,7 @@ void Process::error(QProcess::ProcessError error) analyzeBinary(mBinary); break; case QProcess::Crashed: - printf("Crashed\n"); + printf("Application crashed: %s\n", qPrintable(mBinary)); break; case QProcess::Timedout: printf("Timedout\n"); @@ -222,12 +222,14 @@ void Process::stop() if (kill(mDebuggee, SIGKILL) != 0) perror("Could not kill debugee"); } - if (kill(-getpid(), SIGTERM) != 0) - perror("Could not kill process group"); mProcess->terminate(); if (!mProcess->waitForFinished()) mProcess->kill(); + + // Just for completeness terminate the whole group + // in case the application has started subprocesses + ::kill(-getpid(), SIGTERM); } void Process::incomingConnection(int i) @@ -238,7 +240,7 @@ void Process::incomingConnection(int i) void Process::setSocketNotifier(QSocketNotifier *s) { - connect(s, SIGNAL(activated(int)), this, SLOT(incomingConnection(int))); + connect(s, &QSocketNotifier::activated, this, &Process::incomingConnection); } void Process::setConfig(const Config &config) |