[X2Go-Commits] [x2goclient] 05/139: x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup helper.

git-admin at x2go.org git-admin at x2go.org
Wed Jan 13 17:27:15 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 224de033d650b9bf6bcf774dd3696ce49a7859b0
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Mon Mar 16 20:27:23 2015 +0100

    x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup helper.
---
 debian/changelog   |    2 ++
 src/x2goclient.cpp |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 2bc05ce..3e34d70 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low
     - {unixhelper.{cpp,h},x2goclient.pro{,.maemo}}: add unixhelper stub.
     - unixhelper.{cpp,h}: implement cleanup program for process group.
     - x2goclient.cpp: wrap X2Go Client main function and use that.
+    - x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup
+      helper.
   * 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/x2goclient.cpp b/src/x2goclient.cpp
index 80fd967..f285f40 100644
--- a/src/x2goclient.cpp
+++ b/src/x2goclient.cpp
@@ -15,12 +15,45 @@
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/
 
+#include <iostream>
+#include <unistd.h>
+#include <cstring>
+#include <cerrno>
+#include <cstdlib>
+
+#include "unixhelper.h"
 #include "ongetpass.h"
 
 int wrap_x2go_main (int argc, char **argv) {
   return (x2goMain (argc, argv));
 }
 
+#ifdef Q_OS_UNIX
+int fork_helper (int argc, char **argv) {
+  /* Fork off to start helper process. */
+  pid_t tmp_pid = fork ();
+
+  /* Child. */
+  if (0 == tmp_pid) {
+    /* Starting unixhelper. */
+    unixhelper cleanup_helper ();
+    cleanup_helper.unix_cleanup ();
+  }
+  /* Error. */
+  else if (-1 == tmp_pid) {
+    std::cerr << "Unable to create a new process for the UNIX cleanup watchdog: " << std::strerror (errno) << "\n";
+    std::cerr << "Terminating. Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl;
+
+    std::exit (EXIT_FAILURE);
+  }
+  /* Parent. */
+  else {
+    /* Start real X2Go Client. */
+    return (wrap_x2go_main (argc, argv));
+  }
+}
+#endif /* defined (Q_OS_UNIX) */
+
 int main(int argc, char *argv[])
 {
 	return (wrap_x2go_main (argc, argv));

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