[glib] gmain: Clean up SIGCHLD handling
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gmain: Clean up SIGCHLD handling
- Date: Fri, 3 Jun 2011 15:55:05 +0000 (UTC)
commit 6ea274bca41de8fc6de11d0a5eda22c0efc69ac9
Author: Colin Walters <walters verbum org>
Date: Thu Jun 2 08:56:25 2011 -0400
gmain: Clean up SIGCHLD handling
Unify it more with the rest of the signal handling code. There's
no reason not to specify SA_RESTART and SA_NOCLDSTOP for flags
always, so just do it.
Remove unnecessary initialization, and push the internal API
towards just ensure_unix_signal_handler_installed_unlocked().
https://bugzilla.gnome.org/show_bug.cgi?id=651725
glib/gmain.c | 31 ++++++-------------------------
1 files changed, 6 insertions(+), 25 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index efecbf5..ac8012f 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -375,7 +375,6 @@ static gboolean g_child_watch_dispatch (GSource *source,
#ifdef G_OS_UNIX
static void g_unix_signal_handler (int signum);
static void init_unix_signal_wakeup_state_unlocked (void);
-static void init_unix_signal_wakeup_state (void);
static gboolean g_unix_signal_watch_prepare (GSource *source,
gint *timeout);
static gboolean g_unix_signal_watch_check (GSource *source);
@@ -4394,6 +4393,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;
@@ -4415,7 +4418,7 @@ ensure_unix_signal_handler_installed_unlocked (int signum)
action.sa_handler = g_unix_signal_handler;
sigemptyset (&action.sa_mask);
- action.sa_flags = 0;
+ action.sa_flags = SA_RESTART | SA_NOCLDSTOP;
sigaction (signum, &action, NULL);
}
@@ -4425,8 +4428,6 @@ _g_main_create_unix_signal_watch (int signum)
GSource *source;
GUnixSignalWatchSource *unix_signal_source;
- init_unix_signal_wakeup_state ();
-
source = g_source_new (&g_unix_signal_funcs, sizeof (GUnixSignalWatchSource));
unix_signal_source = (GUnixSignalWatchSource *) source;
@@ -4648,30 +4649,10 @@ init_unix_signal_wakeup_state_unlocked (void)
}
static void
-init_unix_signal_wakeup_state (void)
-{
- G_LOCK (unix_signal_lock);
-
- init_unix_signal_wakeup_state_unlocked ();
-
- G_UNLOCK (unix_signal_lock);
-}
-
-static void
g_child_watch_source_init (void)
{
- init_unix_signal_wakeup_state ();
-
G_LOCK (unix_signal_lock);
- if (!unix_signal_state.sigchld_handler_installed)
- {
- struct sigaction action;
- action.sa_handler = g_unix_signal_handler;
- sigemptyset (&action.sa_mask);
- action.sa_flags = SA_RESTART | SA_NOCLDSTOP;
- sigaction (SIGCHLD, &action, NULL);
- unix_signal_state.sigchld_handler_installed = TRUE;
- }
+ ensure_unix_signal_handler_installed_unlocked (SIGCHLD);
G_UNLOCK (unix_signal_lock);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]