mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 19:36:18 +01:00
gmain: Save errno when handling unix signals
Our signal handler calls write() on a pipe or an eventfd in order to deliver the notification. It's unlikely, but this could fail, setting errno. We even check the case that it fails with EINTR. If it does set errno, then it has potentially blown away the value or errno that the preempted code cared about (ie: if the signal arrived shortly after a system call but before errno was checked). Wrap the handler with code to save errno. https://bugzilla.gnome.org/show_bug.cgi?id=741791
This commit is contained in:
parent
671292bbb2
commit
7c70377abf
@ -5185,10 +5185,14 @@ g_child_watch_dispatch (GSource *source,
|
||||
static void
|
||||
g_unix_signal_handler (int signum)
|
||||
{
|
||||
gint saved_errno = errno;
|
||||
|
||||
unix_signal_pending[signum] = TRUE;
|
||||
any_unix_signal_pending = TRUE;
|
||||
|
||||
g_wakeup_signal (glib_worker_context->wakeup);
|
||||
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
#endif /* !G_OS_WIN32 */
|
||||
|
Loading…
Reference in New Issue
Block a user