summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-26 08:05:49 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-26 08:05:49 +0000
commitf150ed1532e727c409cc018a98e1362a8c71242c (patch)
tree30e5bf9c717ff8b17867b7b5585f32a12952bc7c /signal.c
parent3e0becb42d73be66cd60a0694554eb014b1b6552 (diff)
downloadruby-f150ed1532e727c409cc018a98e1362a8c71242c.tar.gz
* vm_core.h (rb_thread_struct): added 'in_trap' member for marking
running trap handler. * signal.c (signal_exec): turn on in_trap when running trap. * thread.c (Init_Thread, thread_create_core): initialize in_trap when creating new threads. * thread.c (thread_join_m): raise ThreadError when running trap handler.Bug [#6416][ruby-core:44956] * test/ruby/test_thread.rb (test_thread_join_in_trap): new test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/signal.c b/signal.c
index d97d297c1c..9f1717e012 100644
--- a/signal.c
+++ b/signal.c
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <errno.h>
#include "ruby_atomic.h"
+#include "eval_intern.h"
#if defined(__native_client__) && defined(NACL_NEWLIB)
# include "nacl/signal.h"
@@ -623,7 +624,22 @@ static void
signal_exec(VALUE cmd, int safe, int sig)
{
VALUE signum = INT2NUM(sig);
- rb_eval_cmd(cmd, rb_ary_new3(1, signum), safe);
+ rb_thread_t *cur_th = GET_THREAD();
+ int old_in_trap = cur_th->in_trap;
+ int state;
+
+ cur_th->in_trap = 1;
+ TH_PUSH_TAG(cur_th);
+ if ((state = EXEC_TAG()) == 0) {
+ rb_eval_cmd(cmd, rb_ary_new3(1, signum), safe);
+ }
+ TH_POP_TAG();
+ cur_th->in_trap = old_in_trap;
+
+ if (state) {
+ /* XXX: should be replaced with rb_threadptr_async_errinfo_enque() */
+ JUMP_TAG(state);
+ }
}
void