[glib] gmain: Use sigset_t for keeping track of installed signals
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gmain: Use sigset_t for keeping track of installed signals
- Date: Tue, 14 Jun 2011 23:26:09 +0000 (UTC)
commit ed827deb7756bde270eb015eb4263324a313be14
Author: Colin Walters <walters verbum org>
Date: Sat Jun 11 12:10:57 2011 -0400
gmain: Use sigset_t for keeping track of installed signals
Minor code cleanup.
https://bugzilla.gnome.org/show_bug.cgi?id=652072
glib/gmain.c | 37 ++++++++++---------------------------
1 files changed, 10 insertions(+), 27 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 621215c..c95c42c 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -413,16 +413,12 @@ enum {
};
static gint unix_signal_init_state = UNIX_SIGNAL_UNINITIALIZED;
typedef struct {
- gboolean sigchld_handler_installed : 1;
- gboolean sighup_handler_installed : 1;
- gboolean sigint_handler_installed : 1;
- gboolean sigterm_handler_installed : 1;
-
/* These are only used in the UNIX_SIGNAL_INITIALIZED_SINGLE case */
gboolean sighup_delivered : 1;
gboolean sigint_delivered : 1;
gboolean sigterm_delivered : 1;
} UnixSignalState;
+static sigset_t unix_signal_mask;
static UnixSignalState unix_signal_state;
static gint unix_signal_wake_up_pipe[2];
GSList *unix_signal_watches;
@@ -4407,6 +4403,11 @@ ensure_unix_signal_handler_installed_unlocked (int signum)
struct sigaction action;
GError *error = NULL;
+ if (unix_signal_init_state == UNIX_SIGNAL_UNINITIALIZED)
+ {
+ sigemptyset (&unix_signal_mask);
+ }
+
if (unix_signal_init_state == UNIX_SIGNAL_UNINITIALIZED
|| unix_signal_init_state == UNIX_SIGNAL_INITIALIZED_SINGLE)
{
@@ -4432,28 +4433,10 @@ ensure_unix_signal_handler_installed_unlocked (int signum)
}
}
- switch (signum)
- {
- case SIGCHLD:
- if (unix_signal_state.sigchld_handler_installed)
- return;
- unix_signal_state.sigchld_handler_installed = TRUE;
- case SIGHUP:
- if (unix_signal_state.sighup_handler_installed)
- return;
- unix_signal_state.sighup_handler_installed = TRUE;
- break;
- case SIGINT:
- if (unix_signal_state.sigint_handler_installed)
- return;
- unix_signal_state.sigint_handler_installed = TRUE;
- break;
- case SIGTERM:
- if (unix_signal_state.sigterm_handler_installed)
- return;
- unix_signal_state.sigterm_handler_installed = TRUE;
- break;
- }
+ if (sigismember (&unix_signal_mask, signum))
+ return;
+
+ sigaddset (&unix_signal_mask, signum);
action.sa_handler = g_unix_signal_handler;
sigemptyset (&action.sa_mask);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]