[X2Go-Commits] [x2goclient] 23/276: {unixhelper.{cpp, h}, x2goclient.cpp}: switch main cleanup handling to parent PID polling.
git-admin at x2go.org
git-admin at x2go.org
Sat Dec 31 01:34:17 CET 2016
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch bugfix/osx
in repository x2goclient.
commit 8eca258b5f219ec48f908160080feb655184fe7d
Author: Mihai Moldovan <ionic at ionic.de>
Date: Wed Mar 18 21:15:08 2015 +0100
{unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to parent PID polling.
---
debian/changelog | 2 ++
src/unixhelper.cpp | 9 ++++++++-
src/unixhelper.h | 11 +++++++++--
src/x2goclient.cpp | 2 +-
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index f84da0b..1bd2a32 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -55,6 +55,8 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
(which is what execv is doing.)
- unixhelper.{cpp,h}: raise sleeping time to two seconds and grace period
to 10 seconds.
+ - {unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to
+ parent PID polling.
[ Bernard Cafarelli ]
* New upstream version (4.0.5.3):
diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp
index d4698df..410c320 100644
--- a/src/unixhelper.cpp
+++ b/src/unixhelper.cpp
@@ -49,7 +49,7 @@ namespace unixhelper {
}
- int unix_cleanup () {
+ int unix_cleanup (const pid_t parent) {
/*
* Unblock all signals first.
* Signal blocks are inherited, so you never you what is currently set.
@@ -100,6 +100,13 @@ namespace unixhelper {
/* Sleep forever... at least two seconds in each run. */
for (;;) {
+ pid_t cur_ppid = getppid ();
+
+ /* cur_ppid should match parent, otherwise the parent died. */
+ if (cur_ppid != parent) {
+ kill_pgroup (SIGHUP);
+ }
+
sleep (2);
}
}
diff --git a/src/unixhelper.h b/src/unixhelper.h
index 9f213a8..7511d4d 100644
--- a/src/unixhelper.h
+++ b/src/unixhelper.h
@@ -22,6 +22,7 @@
#define UNIXHELPER_H
#include <QtCore/qglobal.h>
+#include <unistd.h>
#ifdef Q_OS_UNIX
@@ -35,8 +36,12 @@ namespace unixhelper {
* the whole process group killed.
*
* Loops indefinitely afterwards.
+ *
+ * In this loop, the current parent PID is polled and compared against
+ * the original value passed via parameter parent.
+ * Should they mismatch, the parent died and kill_pgroup() is called.
*/
- int unix_cleanup ();
+ int unix_cleanup (const pid_t parent);
/*
* Kills the whole process group.
@@ -49,7 +54,9 @@ namespace unixhelper {
* signal may be any of:
* * -1 to indicate an error leading to emergency termination
* * SIGHUP as the standard signal that is sent when the
- * group leeader dies
+ * group leader dies under specific circumstances
+ * (we cannot rely that this always happens, though,
+ * so a polling solution is needed, see unix_cleanup().)
*/
void kill_pgroup (int signal);
}
diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp
index c8df342..2c334e1 100644
--- a/src/x2goclient.cpp
+++ b/src/x2goclient.cpp
@@ -109,7 +109,7 @@ int main (int argc, char **argv) {
if (unix_helper_request) {
/* We were instructed to start as the UNIX cleanup helper tool. */
- return (unixhelper::unix_cleanup ());
+ return (unixhelper::unix_cleanup (getppid ()));
}
else {
/*
--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list