mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 22:46:15 +01:00
Mask all signals in GLib worker thread
Some code using GLib (gnome-keyring-daemon, for example) assumes that they can catch signals by masking them out in the main thread and calling sigwait() from a worker. The problem is that our new worker thread catches the signals before sigwait() has a chance and the default action occurs (typically resulting in program termination). If we mask all the signals in our worker, then this can't happen.
This commit is contained in:
parent
1ed88f0615
commit
51773c6c64
@ -467,6 +467,21 @@ Since: 2.14
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### MACRO G_DEPRECATED ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### MACRO G_DEPRECATED_FOR ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@f:
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO G_LIKELY ##### -->
|
<!-- ##### MACRO G_LIKELY ##### -->
|
||||||
<para>
|
<para>
|
||||||
Hints the compiler that the expression is likely to evaluate to a true
|
Hints the compiler that the expression is likely to evaluate to a true
|
||||||
|
11
glib/gmain.c
11
glib/gmain.c
@ -4757,8 +4757,19 @@ g_get_worker_context (void)
|
|||||||
|
|
||||||
if (g_once_init_enter (&initialised))
|
if (g_once_init_enter (&initialised))
|
||||||
{
|
{
|
||||||
|
/* mask all signals in the worker thread */
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
sigset_t prev_mask;
|
||||||
|
sigset_t all;
|
||||||
|
|
||||||
|
sigfillset (&all);
|
||||||
|
pthread_sigmask (SIG_SETMASK, &all, &prev_mask);
|
||||||
|
#endif
|
||||||
glib_worker_context = g_main_context_new ();
|
glib_worker_context = g_main_context_new ();
|
||||||
g_thread_new ("gmain", glib_worker_main, NULL);
|
g_thread_new ("gmain", glib_worker_main, NULL);
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
pthread_sigmask (SIG_SETMASK, &prev_mask, NULL);
|
||||||
|
#endif
|
||||||
g_once_init_leave (&initialised, TRUE);
|
g_once_init_leave (&initialised, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user