From ce2a3b40ed06a25e9292dd7d02b311510d0ba8e2 Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 30 Jun 2018 00:51:57 +0000 Subject: use SIGCHLD_LOSSY to enable waitpid polling mode Some systems lack SIGCHLD or have incomplete SIGCHLD implementations. So enable polling mode for them. [ruby-core:87705] [Bug #14867] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 6ac7728ad9..401fc0c774 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1375,6 +1375,16 @@ timer_thread_sleep(rb_global_vm_lock_t* gvl) need_polling = !ubf_threads_empty(); + if (SIGCHLD_LOSSY && !need_polling) { + rb_vm_t *vm = container_of(gvl, rb_vm_t, gvl); + + rb_native_mutex_lock(&vm->waitpid_lock); + if (!list_empty(&vm->waiting_pids) || !list_empty(&vm->waiting_grps)) { + need_polling = 1; + } + rb_native_mutex_unlock(&vm->waitpid_lock); + } + if (gvl->waiting > 0 || need_polling) { /* polling (TIME_QUANTUM_USEC usec) */ result = poll(pollfds, 1, TIME_QUANTUM_USEC/1000); -- cgit v1.2.3