Skip to content

Commit 22d4670

Browse files
author
Samuli Piippo
committed
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
2 parents 7e3f7fa + 224cdd8 commit 22d4670

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ int main(int argc, char **argv)
230230
return 1;
231231
}
232232

233+
::setpgid(0,0); // must be called before setsid()
234+
::setsid();
233235
Config config = parseConfigFile();
234236

235237
while (!args.isEmpty()) {
@@ -247,8 +249,6 @@ int main(int argc, char **argv)
247249
}
248250
} else if (arg == "--debug-gdb") {
249251
useGDB = true;
250-
setpgid(0,0); // must be called before setsid()
251-
setsid();
252252
} else if (arg == "--debug-qml") {
253253
useQML = true;
254254
} else if (arg == "--stop") {

process.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ Process::Process()
8888
, mDebug(false)
8989
{
9090
mProcess->setProcessChannelMode(QProcess::SeparateChannels);
91-
connect(mProcess, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
92-
connect(mProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
93-
connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
94-
connect(mProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
95-
connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)), qApp, SLOT(quit()));
91+
connect(mProcess, &QProcess::readyReadStandardError, this, &Process::readyReadStandardError);
92+
connect(mProcess, &QProcess::readyReadStandardOutput, this, &Process::readyReadStandardOutput);
93+
connect(mProcess, (void (QProcess::*)(int, QProcess::ExitStatus))&QProcess::finished, this, &Process::finished);
94+
connect(mProcess, (void (QProcess::*)(QProcess::ProcessError))&QProcess::error, this, &Process::error);
95+
connect(mProcess, (void (QProcess::*)(int, QProcess::ExitStatus))&QProcess::finished, qApp, &QCoreApplication::quit);
9696

9797
if (pipe2(pipefd, O_CLOEXEC) != 0)
9898
qWarning("Could not create pipe");
@@ -150,7 +150,7 @@ void Process::error(QProcess::ProcessError error)
150150
analyzeBinary(mBinary);
151151
break;
152152
case QProcess::Crashed:
153-
printf("Crashed\n");
153+
printf("Application crashed: %s\n", qPrintable(mBinary));
154154
break;
155155
case QProcess::Timedout:
156156
printf("Timedout\n");
@@ -222,12 +222,14 @@ void Process::stop()
222222
if (kill(mDebuggee, SIGKILL) != 0)
223223
perror("Could not kill debugee");
224224
}
225-
if (kill(-getpid(), SIGTERM) != 0)
226-
perror("Could not kill process group");
227225

228226
mProcess->terminate();
229227
if (!mProcess->waitForFinished())
230228
mProcess->kill();
229+
230+
// Just for completeness terminate the whole group
231+
// in case the application has started subprocesses
232+
::kill(-getpid(), SIGTERM);
231233
}
232234

233235
void Process::incomingConnection(int i)
@@ -238,7 +240,7 @@ void Process::incomingConnection(int i)
238240

239241
void Process::setSocketNotifier(QSocketNotifier *s)
240242
{
241-
connect(s, SIGNAL(activated(int)), this, SLOT(incomingConnection(int)));
243+
connect(s, &QSocketNotifier::activated, this, &Process::incomingConnection);
242244
}
243245

244246
void Process::setConfig(const Config &config)

0 commit comments

Comments
 (0)