mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
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
This commit is contained in:
parent
16bdb12e6d
commit
6ea274bca4
31
glib/gmain.c
31
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;
|
||||
|
||||
@ -4647,31 +4648,11 @@ init_unix_signal_wakeup_state_unlocked (void)
|
||||
unix_signal_init_state = UNIX_SIGNAL_INITIALIZED_THREADED;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user