[X2Go-Commits] [x2goclient] 15/44: unixhelper.{cpp, h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation.
git-admin at x2go.org
git-admin at x2go.org
Fri May 22 17:06:07 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 e7494a7a47a89205891994b39b0de9d5cd297dd0
Author: Mihai Moldovan <ionic at ionic.de>
Date: Mon Mar 16 22:42:14 2015 +0100
unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation.
---
debian/changelog | 2 ++
src/unixhelper.cpp | 20 ++++++++++++++++++++
src/unixhelper.h | 10 +++++-----
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 84f61ce..096543e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -422,6 +422,8 @@ x2goclient (4.0.4.0-0x2go1) UNRELEASED; urgency=low
- unixhelper.{cpp,h}: add documentation/comments.
- x2goclient.cpp: return return value of unixhelper::unix_cleanup().
- unixhelper.cpp: kill process group on error.
+ - unixhelper.{cpp,h}: implement signal unblocking in
+ unixhelper::unix_cleanup(). Update documentation.
[ Fernando Pedemonte ]
* New upstream release (4.0.4.0):
diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp
index d9ef3d7..1877890 100644
--- a/src/unixhelper.cpp
+++ b/src/unixhelper.cpp
@@ -54,6 +54,26 @@ namespace unixhelper {
int unix_cleanup () {
+ /*
+ * Unblock all signals first.
+ * Signal blocks are inherited, so you never you what is currently set.
+ */
+ sigset_t empty_set;
+ if (0 != sigemptyset (&empty_set)) {
+ std::cerr << "Unable to fetch empty signal set: " << std::strerror (errno) << std::endl;
+ kill_pgroup (-1);
+
+ /* Anything here shall be unreachable. */
+ }
+
+ if (0 != sigprocmask (SIG_SETMASK, &empty_set, NULL)) {
+ std::cerr << "Unable to set empty signal set: " << std::strerror (errno) << std::endl;
+ kill_pgroup (-1);
+
+ /* Anything here shall be unreachable. */
+ }
+
+ /* Set up signal handler to ignore SIGTERM. */
if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) {
std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl;
kill_pgroup (-1);
diff --git a/src/unixhelper.h b/src/unixhelper.h
index a00d21b..7ca8b43 100644
--- a/src/unixhelper.h
+++ b/src/unixhelper.h
@@ -27,12 +27,12 @@
namespace unixhelper {
/*
- * TODO: Unblocks all signals and
- * installs a signal handler for SIGHUP, which calls kill_pgroup.
+ * Unblocks all signals and installs a signal handler for SIGHUP,
+ * which calls kill_pgroup.
*
- * TODO: Should signal unblocking or
- * installing the signal handler fail, an emergency exit is performed
- * and the whole process group killed.
+ * Should signal unblocking or installing the signal handler fail,
+ * an emergency exit is performed and
+ * the whole process group killed.
*
* Loops indefinitely afterwards.
*/
--
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