This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 08b935e8d3faa221530cca5b85d03e164d7bbdc4 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 22:04:19 2015 +0100 unixhelper.{cpp,h}: add documentation/comments. --- debian/changelog | 1 + src/unixhelper.cpp | 4 ++++ src/unixhelper.h | 24 ++++++++++++++++++++++++ src/x2goclient.cpp | 2 ++ 4 files changed, 31 insertions(+) diff --git a/debian/changelog b/debian/changelog index 4a33d8d..5b07a82 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - unixhelper.h: forgot to declare type of unix_cleanup() function. - {unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class. + - unixhelper.{cpp,h}: add documentation/comments. * debian/control: - Change apache2-dev | libc6-dev build dependency back to apache2-dev only. Otherwise, apache2-dev is not installed at all, even though diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index b0729c6..2ad0740 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -30,6 +30,8 @@ #include <cerrno> #include <cstdlib> +/* For documentation please see unixhelper.h. */ + namespace unixhelper { void kill_pgroup (int signal) { if (SIGHUP == signal) { @@ -51,6 +53,8 @@ namespace unixhelper { if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) { std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; std::exit (1); + + /* Anything here shall be unreachable. */ } std::signal (SIGHUP, kill_pgroup); diff --git a/src/unixhelper.h b/src/unixhelper.h index fe86017..a00d21b 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -26,7 +26,31 @@ #ifdef Q_OS_UNIX namespace unixhelper { + /* + * TODO: Unblocks all signals and + * installs a signal handler for SIGHUP, which calls kill_pgroup. + * + * TODO: Should signal unblocking or + * installing the signal handler fail, an emergency exit is performed + * and the whole process group killed. + * + * Loops indefinitely afterwards. + */ int unix_cleanup (); + + /* + * Kills the whole process group. + * First, SIGTERM is sent to the group. + * A 5 seconds grace period is granted to make sure + * processes exit cleanly on their own. + * Lastly, SIGKILL is sent to the group -- which also + * implies the demise of this program. + * + * 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 + */ void kill_pgroup (int signal); } diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 005d819..de3b7c9 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -39,6 +39,8 @@ int fork_helper (int argc, char **argv) { if (0 == tmp_pid) { /* Starting unixhelper. */ unixhelper::unix_cleanup (); + + /* Anything here shall be unreachable. */ } /* Error. */ else if (-1 == tmp_pid) { -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git