[X2Go-Commits] [x2goclient] 15/217: unixhelper.{cpp, h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation.

git-admin at x2go.org git-admin at x2go.org
Sat Aug 27 19:24:15 CEST 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 89ecda0a4150e57991abc62428568095ff0fb93a
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Mon Mar 16 22:42:14 2015 +0100

    unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation.
---
 debian/changelog   |    2 ++
 src/unixhelper.cpp |   20 ++++++++++++++++++++
 src/unixhelper.h   |   10 +++++-----
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 224dfbf..3ce2069 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -59,6 +59,8 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium
     - unixhelper.{cpp,h}: add documentation/comments.
     - x2goclient.cpp: return return value of unixhelper::unix_cleanup().
     - unixhelper.cpp: kill process group on error.
+    - unixhelper.{cpp,h}: implement signal unblocking in
+      unixhelper::unix_cleanup(). Update documentation.
   * debian/control:
     - Maintainer change in package: X2Go Developers <x2go-dev at lists.x2go.org>.
     - Uploaders: add myself. Also, force a rebuild due to the changed
diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp
index 2ad0740..f2cc11c 100644
--- a/src/unixhelper.cpp
+++ b/src/unixhelper.cpp
@@ -50,6 +50,26 @@ namespace unixhelper {
 
 
   int unix_cleanup () {
+    /*
+     * Unblock all signals first.
+     * Signal blocks are inherited, so you never you what is currently set.
+     */
+    sigset_t empty_set;
+    if (0 != sigemptyset (&empty_set)) {
+      std::cerr << "Unable to fetch empty signal set: " << std::strerror (errno) << std::endl;
+      kill_pgroup (-1);
+
+      /* Anything here shall be unreachable. */
+    }
+
+    if (0 != sigprocmask (SIG_SETMASK, &empty_set, NULL)) {
+      std::cerr << "Unable to set empty signal set: " << std::strerror (errno) << std::endl;
+      kill_pgroup (-1);
+
+      /* Anything here shall be unreachable. */
+    }
+
+    /* Set up signal handler to ignore SIGTERM. */
     if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) {
       std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl;
       std::exit (1);
diff --git a/src/unixhelper.h b/src/unixhelper.h
index a00d21b..7ca8b43 100644
--- a/src/unixhelper.h
+++ b/src/unixhelper.h
@@ -27,12 +27,12 @@
 
 namespace unixhelper {
   /*
-   * TODO: Unblocks all signals and
-   * installs a signal handler for SIGHUP, which calls kill_pgroup.
+   * 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.
+   * Should signal unblocking or installing the signal handler fail,
+   * an emergency exit is performed and
+   * the whole process group killed.
    *
    * Loops indefinitely afterwards.
    */

--
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