[X2Go-Commits] [x2goclient] 24/44: unixhelper.{cpp, h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and SIGUSR2.
git-admin at x2go.org
git-admin at x2go.org
Tue May 12 04:53:11 CEST 2015
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch bugfix/osx
in repository x2goclient.
commit d50f8262e5b993b01e89cbf9d49dc2e3d4d0cfb7
Author: Mihai Moldovan <ionic at 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 | 17 +++++++++++++----
src/unixhelper.h | 3 +++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 059710d..637ef7e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -437,6 +437,8 @@ x2goclient (4.0.4.0-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.
[ Fernando Pedemonte ]
* New upstream release (4.0.4.0):
diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp
index 2f89e2f..afc7b60 100644
--- a/src/unixhelper.cpp
+++ b/src/unixhelper.cpp
@@ -28,6 +28,7 @@
#include <iostream>
#include <cstring>
#include <cerrno>
+#include <vector>
/* For documentation please see unixhelper.h. */
@@ -73,15 +74,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
More information about the x2go-commits
mailing list