aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-11-13 01:20:33 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-11-20 22:09:45 +0900
commita7359ee08be07abdeafd5803b6c92bf06ee20298 (patch)
tree1881f85e367a4248e0e69fde8f93d433ce75fac2
parent5e8c9c51a52b3ebfdd62fd7df4f0b93aecc9c38f (diff)
downloadruby-a7359ee08be07abdeafd5803b6c92bf06ee20298.tar.gz
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.
-rw-r--r--thread.c11
1 files 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