From a7359ee08be07abdeafd5803b6c92bf06ee20298 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Sun, 13 Nov 2016 01:20:33 +0900 Subject: thread.c: make thread_debug() print to stderr Make thread_debug() print to stderr rather than stdout. The current behavior is inconvenient because it causes "make all" to fail if THREAD_DEBUG is set to 1. --- thread.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/thread.c b/thread.c index c596b5bc12..096ac036ba 100644 --- a/thread.c +++ b/thread.c @@ -263,7 +263,7 @@ rb_thread_s_debug_set(VALUE self, VALUE val) #endif #ifndef fill_thread_id_str -# define fill_thread_id_string(thid, buf) (thid) +# define fill_thread_id_string(thid, buf) ((void *)(thid)) # define fill_thread_id_str(th) (void)0 # define thread_id_str(th) ((void *)(th)->thread_id) # define PRI_THREAD_ID "p" @@ -281,8 +281,8 @@ static void timer_thread_function(void *); #define DEBUG_OUT() \ WaitForSingleObject(&debug_mutex, INFINITE); \ - printf(POSITION_FORMAT"%#lx - %s" POSITION_ARGS, GetCurrentThreadId(), buf); \ - fflush(stdout); \ + fprintf(stderr, POSITION_FORMAT"%#lx - %s" POSITION_ARGS, \ + GetCurrentThreadId(), buf); \ ReleaseMutex(&debug_mutex); #elif defined(HAVE_PTHREAD_H) @@ -290,9 +290,8 @@ static void timer_thread_function(void *); #define DEBUG_OUT() \ pthread_mutex_lock(&debug_mutex); \ - printf(POSITION_FORMAT"%"PRI_THREAD_ID" - %s" POSITION_ARGS, \ - fill_thread_id_string(pthread_self(), thread_id_string), buf); \ - fflush(stdout); \ + fprintf(stderr, POSITION_FORMAT"%"PRI_THREAD_ID" - %s" POSITION_ARGS, \ + fill_thread_id_string(pthread_self(), thread_id_string), buf); \ pthread_mutex_unlock(&debug_mutex); #else -- cgit v1.2.3