diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-03 01:37:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-03 01:37:00 +0000 |
commit | 09c96a7858955f2b94238bd4bf38729f0d650f22 (patch) | |
tree | 618aecd08aedb8cd6b1ed368187624743b34896f /thread_pthread.c | |
parent | 0b991b657909fa30bbeb6ffb8995cd2c3c8bdc92 (diff) | |
download | ruby-09c96a7858955f2b94238bd4bf38729f0d650f22.tar.gz |
thread_pthread.c: set thread name
* thread_pthread.c (thread_timer): set timer thread name on OSX too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index 74d1ab7517..3911f8fcff 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1416,6 +1416,15 @@ timer_thread_sleep(rb_global_vm_lock_t* unused) } #endif /* USE_SLEEPY_TIMER_THREAD */ +#if defined(__linux__) && defined(PR_SET_NAME) +# define SET_THREAD_NAME(name) prctl(PR_SET_NAME, name) +#elif defined(__APPLE__) +/* pthread_setname_np() on Darwin does not have target thread argument */ +# define SET_THREAD_NAME(name) pthread_setname_np(name) +#else +# define SET_THREAD_NAME(name) (void)0 +#endif + static void * thread_timer(void *p) { @@ -1423,9 +1432,7 @@ thread_timer(void *p) if (TT_DEBUG) WRITE_CONST(2, "start timer thread\n"); -#if defined(__linux__) && defined(PR_SET_NAME) - prctl(PR_SET_NAME, "ruby-timer-thr"); -#endif + SET_THREAD_NAME("ruby-timer-thr"); #if !USE_SLEEPY_TIMER_THREAD native_mutex_initialize(&timer_thread_lock); |