mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-30 20:33:08 +02:00
gmain: Use sigset_t for keeping track of installed signals
Minor code cleanup. https://bugzilla.gnome.org/show_bug.cgi?id=652072
This commit is contained in:
parent
1874ad97d8
commit
ed827deb77
37
glib/gmain.c
37
glib/gmain.c
@ -413,16 +413,12 @@ enum {
|
|||||||
};
|
};
|
||||||
static gint unix_signal_init_state = UNIX_SIGNAL_UNINITIALIZED;
|
static gint unix_signal_init_state = UNIX_SIGNAL_UNINITIALIZED;
|
||||||
typedef struct {
|
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 */
|
/* These are only used in the UNIX_SIGNAL_INITIALIZED_SINGLE case */
|
||||||
gboolean sighup_delivered : 1;
|
gboolean sighup_delivered : 1;
|
||||||
gboolean sigint_delivered : 1;
|
gboolean sigint_delivered : 1;
|
||||||
gboolean sigterm_delivered : 1;
|
gboolean sigterm_delivered : 1;
|
||||||
} UnixSignalState;
|
} UnixSignalState;
|
||||||
|
static sigset_t unix_signal_mask;
|
||||||
static UnixSignalState unix_signal_state;
|
static UnixSignalState unix_signal_state;
|
||||||
static gint unix_signal_wake_up_pipe[2];
|
static gint unix_signal_wake_up_pipe[2];
|
||||||
GSList *unix_signal_watches;
|
GSList *unix_signal_watches;
|
||||||
@ -4407,6 +4403,11 @@ ensure_unix_signal_handler_installed_unlocked (int signum)
|
|||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (unix_signal_init_state == UNIX_SIGNAL_UNINITIALIZED)
|
||||||
|
{
|
||||||
|
sigemptyset (&unix_signal_mask);
|
||||||
|
}
|
||||||
|
|
||||||
if (unix_signal_init_state == UNIX_SIGNAL_UNINITIALIZED
|
if (unix_signal_init_state == UNIX_SIGNAL_UNINITIALIZED
|
||||||
|| unix_signal_init_state == UNIX_SIGNAL_INITIALIZED_SINGLE)
|
|| unix_signal_init_state == UNIX_SIGNAL_INITIALIZED_SINGLE)
|
||||||
{
|
{
|
||||||
@ -4432,28 +4433,10 @@ ensure_unix_signal_handler_installed_unlocked (int signum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (signum)
|
if (sigismember (&unix_signal_mask, signum))
|
||||||
{
|
return;
|
||||||
case SIGCHLD:
|
|
||||||
if (unix_signal_state.sigchld_handler_installed)
|
sigaddset (&unix_signal_mask, signum);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
action.sa_handler = g_unix_signal_handler;
|
action.sa_handler = g_unix_signal_handler;
|
||||||
sigemptyset (&action.sa_mask);
|
sigemptyset (&action.sa_mask);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user