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

git-admin at x2go.org git-admin at x2go.org
Sat Aug 27 19:24:11 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 07c2e0499aa73a8c8e397f6114c8ff65521aee62
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 7dde616..5214e87 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -41,6 +41,8 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium
     - {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:
     - 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/x2goclient.cpp b/src/x2goclient.cpp
index fb63fe5..df15858 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