summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <rainer.keller@digia.com>2014-07-28 13:10:23 +0200
committerRainer Keller <rainer.keller@digia.com>2014-08-14 09:28:38 +0300
commit224cdd83d41d659ec166f7177a549d391ed1d5cc (patch)
tree2ec6c8e09e362dd2a179db75985288b4e9d2efd4
parenta6a806bc5e34dfaad1a39fffb237838f2f70a484 (diff)
Always create a process group and session
Task-number: QTEE-641 Change-Id: Id2476d51834f29be8f7628f61642f9f9d552ccda Reviewed-by: Rainer Keller <rainer.keller@digia.com>
-rw-r--r--main.cpp4
-rw-r--r--process.cpp6
2 files changed, 6 insertions, 4 deletions
diff --git a/main.cpp b/main.cpp
index 676b4ab..51e69d1 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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 abf3eab..0584ccf 100644
--- a/process.cpp
+++ b/process.cpp
@@ -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)