[X2Go-Commits] [x2goclient] 12/139: unixhelper.{cpp, h}, x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class.

git-admin at x2go.org git-admin at x2go.org
Sun Jan 17 06:02:37 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 65bc20a090bddfacc1485b160e46c6f1205d3f8d
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Mon Mar 16 21:38:10 2015 +0100

    unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class.
---
 debian/changelog   |    2 ++
 src/unixhelper.cpp |   43 ++++++++++++++++++++++---------------------
 src/unixhelper.h   |   14 ++++----------
 src/x2goclient.cpp |    3 +--
 4 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 94812ab..4a33d8d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -38,6 +38,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low
     - unixhelper.{h,cpp}: also include <QtCore/qglobal.h> to have Q_OS_UNIX
       defined on UNIX-based platforms. Move guards around.
     - 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.
   * 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 b326f35..b0729c6 100644
--- a/src/unixhelper.cpp
+++ b/src/unixhelper.cpp
@@ -30,34 +30,35 @@
 #include <cerrno>
 #include <cstdlib>
 
+namespace unixhelper {
+  void kill_pgroup (int signal) {
+    if (SIGHUP == signal) {
+      /* Try to kill via SIGTERM first. */
+      if (0 != killpg (getpgrp (), SIGTERM)) {
+        std::cerr << "WARNING: unable to send SIGTERM to process group: " << std::strerror (errno) << std::endl;
+      }
 
-void unixhelper::kill_pgroup (int signal) {
-  if (SIGHUP == signal) {
-    /* Try to kill via SIGTERM first. */
-    if (0 != killpg (getpgrp (), SIGTERM)) {
-      std::cerr << "WARNING: unable to send SIGTERM to process group: " << std::strerror (errno) << std::endl;
-    }
-
-    /* Grant a grace period of (at least) 5 seconds. */
-    sleep (5);
+      /* Grant a grace period of (at least) 5 seconds. */
+      sleep (5);
 
-    /* Don't handle any errors here, because we die anyway. */
-    killpg (getpgrp (), SIGKILL);
+      /* Don't handle any errors here, because we die anyway. */
+      killpg (getpgrp (), SIGKILL);
+    }
   }
-}
 
 
-int unixhelper::unix_cleanup () {
-  if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) {
-    std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl;
-    std::exit (1);
-  }
+  int unix_cleanup () {
+    if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) {
+      std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl;
+      std::exit (1);
+    }
 
-  std::signal (SIGHUP, kill_pgroup);
+    std::signal (SIGHUP, kill_pgroup);
 
-  /* Sleep forever... at least one second in each run. */
-  for (;;) {
-    sleep (1);
+    /* Sleep forever... at least one second in each run. */
+    for (;;) {
+      sleep (1);
+    }
   }
 }
 
diff --git a/src/unixhelper.h b/src/unixhelper.h
index 9069b5d..fe86017 100644
--- a/src/unixhelper.h
+++ b/src/unixhelper.h
@@ -25,16 +25,10 @@
 
 #ifdef Q_OS_UNIX
 
-class unixhelper {
-  public:
-    unixhelper () {}
-    ~unixhelper () {}
-    int unix_cleanup ();
-
-  private:
-    unixhelper (const unixhelper &other);
-    void kill_pgroup (int signal);
-};
+namespace unixhelper {
+  int unix_cleanup ();
+  void kill_pgroup (int signal);
+}
 
 #endif /* defined (Q_OS_UNIX) */
 
diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp
index f495796..7eb6511 100644
--- a/src/x2goclient.cpp
+++ b/src/x2goclient.cpp
@@ -38,8 +38,7 @@ int fork_helper (int argc, char **argv) {
   /* Child. */
   if (0 == tmp_pid) {
     /* Starting unixhelper. */
-    unixhelper cleanup_helper ();
-    cleanup_helper.unix_cleanup ();
+    unixhelper::unix_cleanup ();
   }
   /* 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


More information about the x2go-commits mailing list