This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit d08cab87071a1ec00e5554d07d9d7be4df64aacb Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 22:22:27 2015 +0100 unixhelper.{cpp,h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and SIGUSR2. --- debian/changelog | 2 ++ src/unixhelper.cpp | 18 +++++++++++++----- src/unixhelper.h | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 16dad03..6a4d3d0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -64,6 +64,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low to 10 seconds. - {unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to parent PID polling. + - unixhelper.{cpp,h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 + and SIGUSR2. * 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 410c320..acdee33 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -28,7 +28,7 @@ #include <iostream> #include <cstring> #include <cerrno> -#include <cstdlib> +#include <vector> /* For documentation please see unixhelper.h. */ @@ -69,15 +69,23 @@ namespace unixhelper { /* Anything here shall be unreachable. */ } - { + std::vector<int> ignore_signals; + ignore_signals.push_back (SIGINT); + ignore_signals.push_back (SIGTERM); + ignore_signals.push_back (SIGPIPE); + ignore_signals.push_back (SIGQUIT); + ignore_signals.push_back (SIGUSR1); + ignore_signals.push_back (SIGUSR2); + + for (std::vector<int>::iterator it = ignore_signals.begin (); it != ignore_signals.end (); ++it) { struct sigaction sig_action; sig_action.sa_handler = SIG_IGN; sig_action.sa_mask = empty_set; sig_action.sa_flags = SA_RESTART; - /* Set up signal handler to ignore SIGTERM. */ - if (0 != sigaction (SIGTERM, &sig_action, NULL)) { - std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; + /* Set up signal handler to ignore the current signal. */ + if (0 != sigaction (*it, &sig_action, NULL)) { + std::cerr << "Unable to ignore signal " << strsignal (*it) << ": " << std::strerror (errno) << std::endl; kill_pgroup (-1); /* Anything here shall be unreachable. */ diff --git a/src/unixhelper.h b/src/unixhelper.h index 7511d4d..a34456e 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -35,6 +35,9 @@ namespace unixhelper { * an emergency exit is performed and * the whole process group killed. * + * The signals SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and + * SIGUSR2 are ignored. + * * Loops indefinitely afterwards. * * In this loop, the current parent PID is polled and compared against -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git