From 594ce15c55f0a717b365f3ed7f3e6880a85b4a2f Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 10 Jan 2012 21:00:59 +0400 Subject: [PATCH] Fix GC_restart_handler to preserve errno if needed * pthread_stop_world.c (GC_restart_handler): Preserve errno value in case of sem_post or GC_log_printf invocation inside. --- pthread_stop_world.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pthread_stop_world.c b/pthread_stop_world.c index ebe010ec..26326842 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -270,6 +270,10 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, STATIC void GC_restart_handler(int sig) { +# if defined(DEBUG_THREADS) || defined(GC_NETBSD_THREADS_WORKAROUND) + int old_errno = errno; /* Preserve errno value. */ +# endif + if (sig != SIG_THR_RESTART) ABORT("Bad signal in suspend_handler"); # ifdef GC_NETBSD_THREADS_WORKAROUND @@ -287,6 +291,9 @@ STATIC void GC_restart_handler(int sig) # ifdef DEBUG_THREADS GC_log_printf("In GC_restart_handler for %p\n", (void *)pthread_self()); # endif +# if defined(DEBUG_THREADS) || defined(GC_NETBSD_THREADS_WORKAROUND) + errno = old_errno; +# endif } #endif /* !GC_OPENBSD_THREADS && !NACL */ -- 2.40.0