This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient.
commit 52be70628ff718aabb96fe0101e42d2824d591d0 Author: Mihai Moldovan <io...@ionic.de> Date: Mon Mar 16 23:41:12 2015 +0100 x2goclient.cpp: clean up. We don't care if setsid() fails or succeeds and we certainly do not need to fork to force it to succeed. Whether we are a process group leader already or become one doesn't matter, if the end result is that we are process group leader. --- debian/changelog | 4 ++++ src/x2goclient.cpp | 42 ++++++++---------------------------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/debian/changelog b/debian/changelog index e7d0429..49d9d4f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,10 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium - unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation. - unixhelper.cpp: port from std::signal() to sigaction(). Handle errors. + - x2goclient.cpp: clean up. We don't care if setsid() fails or succeeds + and we certainly do not need to fork to force it to succeed. Whether we + are a process group leader already or become one doesn't matter, if the + end result is that we are process group leader. -- X2Go Release Manager <git-ad...@x2go.org> Mon, 19 Sep 2016 09:07:07 +0200 diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index be070d8..ad613fb 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -59,41 +59,15 @@ int fork_helper (int argc, char **argv) { int main (int argc, char **argv) { #ifdef Q_OS_UNIX - if (-1 == setsid ()) { - std::cerr << "Unable to create a new process session: " << std::strerror (errno) << "\n"; + /* + * setsid() may succeed and we become a session and process + * group leader, or it may fail indicating that we already + * are a process group leader. Either way is fine. + */ + setsid (); - std::cerr << "Trying to fork." << std::endl; - pid_t tmp_pid = fork (); - - /* Child. */ - if (0 == tmp_pid) { - /* Trying to get a new session and become session + process group leader again. */ - if (-1 == setsid ()) { - std::cerr << "Child was unable to create a new process session: " << 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); - } - - /* By now, we should be session and group leader. */ - return (fork_helper (argc, argv)); - } - /* Error. */ - else if (-1 == tmp_pid) { - std::cerr << "Error while forking: " << std::strerror (errno) << std::endl; - 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. Just die here. */ - else { - std::exit (EXIT_SUCCESS); - } - } - else { - /* setsid() worked. Starting helper and main program. */ - return (fork_helper (argc, argv)); - } + /* We should be process group leader by now. */ + return (fork_helper (argc, argv)); #else /* defined (Q_OS_UNIX) */ return (wrap_x2go_main (argc, argv)); #endif /* defined (Q_OS_UNIX) */ -- 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