diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-10 03:59:49 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-10 03:59:49 +0000 |
commit | 383a2579c3027e579f64e08597bae1097619baf4 (patch) | |
tree | 1317a3313038e6639d83cc16050428ecb6fc13b8 /process.c | |
parent | 368fdf9cc164caef3ea08cdd9226542de943479f (diff) | |
download | ruby-383a2579c3027e579f64e08597bae1097619baf4.tar.gz |
* thread_pthread.c (rb_thread_create_timer_thread): factor out
creating communication pipe logic into separate function.
* thread_pthread.c (setup_communication_pipe): new helper function.
* thread_pthread.c (set_nonblock): moves a definition before
setup_communication_pipe.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -1080,6 +1080,32 @@ before_exec_non_async_signal_safe(void) } static void +setup_communication_pipe(void) +{ +#if USE_SLEEPY_TIMER_THREAD + /* communication pipe with timer thread and signal handler */ + if (timer_thread_pipe_owner_process != getpid()) { + if (timer_thread_pipe[0] != -1) { + /* close pipe of parent process */ + close_communication_pipe(); + } + + err = rb_cloexec_pipe(timer_thread_pipe); + if (err != 0) { + rb_bug_errno("thread_timer: Failed to create communication pipe for timer thread", errno); + } + rb_update_max_fd(timer_thread_pipe[0]); + rb_update_max_fd(timer_thread_pipe[1]); + set_nonblock(timer_thread_pipe[0]); + set_nonblock(timer_thread_pipe[1]); + + /* validate pipe on this process */ + timer_thread_pipe_owner_process = getpid(); + } +#endif /* USE_SLEEPY_TIMER_THREAD */ +} + +static void before_exec(void) { before_exec_non_async_signal_safe(); |