This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit 268b43151ead30e3a183eaf27531a4bcb1213854
Author: Mihai Moldovan <io...@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 51c2e58..6dd8c2c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -30,6 +30,8 @@ x2goclient (4.0.5.3-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.
 
  -- X2Go Release Manager <git-ad...@x2go.org>  Mon, 19 Sep 2016 09:07:07 +0200
 
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
_______________________________________________
x2go-commits mailing list
x2go-commits@lists.x2go.org
http://lists.x2go.org/listinfo/x2go-commits

Reply via email to