Bug #968: trap may fail to handle signals
http://redmine.ruby-lang.org/issues/show/968
e$B5/I<<Te(B: Yusuke E.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$BC4Ev<Te(B: Koichi Sasada, e$B%+%F%4%je(B: YARV, Target version: 1.9.1
RC2
e$B1sF#$G$9!#e(B
e$B%7%0%J%k$,O"B3$7$FAw$i$l$?$H$-!"%7%0%J%k$rFI$Mn$H$9$3$H$,e(B
e$B$"$k$h$&$G$9!#6qBNE*$K$O!"0J2<$N%W%m%0%i%`$,Dd;$7$^$;$s!#e(B
./ruby -e ’
n = 0
trap(:USR1) { n += 1 }
30.times { Process.kill(:USR1, $$) }
until n == 30
1000**100000 # wait
p n
end
’
e$B$3$l$O;EMM$G$7$g$&$+!#e(B
e$B;EMM$G$J$1$l$P!"0J2<$N$h$&$J%Q%C%A$G$I$&$G$7$g$&$+!#e(B
Index: thread.c
— thread.c (revision 21269)
+++ thread.c (working copy)
@@ -1145,6 +1145,10 @@
void
rb_thread_execute_interrupts(rb_thread_t *th)
{
-
if (GET_VM()->main_thread == th) {
-
while (rb_signal_buff_size() && !th->exec_signal)
native_thread_yield(); -
}
-
if (th->raised_flag) return;
while (th->interrupt_flag) {
@@ -2438,13 +2442,14 @@
{
rb_vm_t vm = GET_VM(); / TODO: fix me for Multi-VM */
int sig; -
rb_thread_t *mth;
/* for time slice */
RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread);/* check signal */
- if ((sig = rb_get_next_signal()) > 0) {
- rb_thread_t *mth = vm->main_thread;
- mth = vm->main_thread;
- if (!mth->exec_signal && (sig = rb_get_next_signal()) > 0) {
enum rb_thread_status prev_status = mth->status;
thread_debug(“main_thread: %s, sig: %d\n”,
thread_status_name(prev_status), sig);
–
Yusuke ENDOH [email protected]