summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-01 07:59:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-01 07:59:18 +0000
commitd9acb91ae3afe2c96e6c1f1bc432cf88b89add33 (patch)
tree40e26edf76735bd933d38098b54b0d3950800ead
parent6f8f8959b7da90d56398b033c2c8e0da6f4ade64 (diff)
* eval.c (rb_thread_switch): add RESTORE_EXIT; exit by another
thread termination. * eval.c (rb_thread_start_0): should not error_print() within terminated thread, because $stderr used by it might be overriden now. [ruby-dev:21280] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog17
-rw-r--r--eval.c42
2 files changed, 41 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 356d2fcadc..65d1c6ee35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon Sep 1 16:59:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (rb_thread_switch): add RESTORE_EXIT; exit by another
+ thread termination.
+
+ * eval.c (rb_thread_start_0): should not error_print() within
+ terminated thread, because $stderr used by it might be
+ overriden now. [ruby-dev:21280]
+
Sun Aug 31 22:46:55 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* eval.c (TAG_DST()): take no argument.
@@ -46,7 +55,7 @@ Fri Aug 29 17:30:15 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* process.c: add rb_secure(2) to methods of Process::{UID,GID,Sys}
- * process.c: deny handling IDs during evaluating the block given to
+ * process.c: deny handling IDs during evaluating the block given to
the Process::{UID,GID}.switch method
* ext/tcltklib/tcltklib.c : some methods have no effect if on slave-IP
@@ -61,16 +70,16 @@ Fri Aug 29 17:30:15 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb : more secure
- * ext/tk/lib/tk.rb: TkVariable.new(array) --> treat the array as the
+ * ext/tk/lib/tk.rb: TkVariable.new(array) --> treat the array as the
Tk's list
* ext/tk/lib/tk.rb: improve accessibility of TkVariable object
- * ext/tk/lib/tk.rb, ext/tk/lib/tkfont.rb, ext/tk/lib/tkcanvas.rb,
+ * ext/tk/lib/tk.rb, ext/tk/lib/tkfont.rb, ext/tk/lib/tkcanvas.rb,
ext/tk/lib/tktext.rb : fix bug of font handling
* ext/tk/lib/tkfont.rb TkFont.new() accepts compound fonts
-
+
Thu Aug 28 22:07:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_autoload_load): call const_missing if autoloading
diff --git a/eval.c b/eval.c
index 4fbdca7752..3765ae8600 100644
--- a/eval.c
+++ b/eval.c
@@ -3761,10 +3761,9 @@ rb_mod_protected_method_defined(mod, mid)
return Qfalse;
}
-#define terminate_process(status, mesg, mlen) rb_exc_raise(system_exit(status, mesg, mlen))
-
+NORETURN(static VALUE terminate_process _((int, const char *, long)));
static VALUE
-system_exit(status, mesg, mlen)
+terminate_process(status, mesg, mlen)
int status;
const char *mesg;
long mlen;
@@ -3773,7 +3772,7 @@ system_exit(status, mesg, mlen)
args[0] = INT2NUM(status);
args[1] = rb_str_new(mesg, mlen);
- return rb_class_new_instance(2, args, rb_eSystemExit);
+ rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit));
}
void
@@ -8159,6 +8158,7 @@ static char *th_signm;
#define RESTORE_TRAP 4
#define RESTORE_RAISE 5
#define RESTORE_SIGNAL 6
+#define RESTORE_EXIT 7
extern VALUE *rb_gc_stack_start;
@@ -8251,6 +8251,12 @@ rb_thread_switch(n)
case RESTORE_SIGNAL:
rb_raise(rb_eSignal, "SIG%s", th_signm);
break;
+ case RESTORE_EXIT:
+ ruby_errinfo = th_raise_argv[0];
+ ruby_current_node = th_raise_node;
+ error_print();
+ terminate_process(1, 0, 0);
+ break;
case RESTORE_NORMAL:
default:
break;
@@ -8269,7 +8275,7 @@ rb_thread_switch(n)
rb_thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
#endif
-static void rb_thread_restore_context _((rb_thread_t,int));
+NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
static void
stack_extend(th, exit)
@@ -8411,6 +8417,20 @@ rb_thread_fd_close(fd)
END_FOREACH(th);
}
+NORETURN(static void rb_thread_main_jump _((VALUE, int)));
+static void
+rb_thread_main_jump(err, tag)
+ VALUE err;
+ int tag;
+{
+ curr_thread = main_thread;
+ th_raise_argc = 1;
+ th_raise_argv[0] = err;
+ th_raise_node = ruby_current_node;
+ rb_thread_restore_context(main_thread, tag);
+}
+
+NORETURN(static void rb_thread_deadlock _((void)));
static void
rb_thread_deadlock()
{
@@ -8422,11 +8442,7 @@ rb_thread_deadlock()
if (curr_thread == main_thread) {
rb_exc_raise(e);
}
- curr_thread = main_thread;
- th_raise_argc = 1;
- th_raise_argv[0] = e;
- th_raise_node = ruby_current_node;
- rb_thread_restore_context(main_thread, RESTORE_RAISE);
+ rb_thread_main_jump(e, RESTORE_RAISE);
}
static void
@@ -9419,14 +9435,12 @@ rb_thread_start_0(fn, arg, th_arg)
}
else {
/* delegate exception to main_thread */
- rb_thread_raise(1, &ruby_errinfo, main_thread);
+ rb_thread_main_jump(ruby_errinfo, RESTORE_RAISE);
}
}
else if (th->safe < 4 && (ruby_thread_abort || th->abort || RTEST(ruby_debug))) {
- VALUE err = system_exit(1, 0, 0);
- error_print();
/* exit on main_thread */
- rb_thread_raise(1, &err, main_thread);
+ rb_thread_main_jump(ruby_errinfo, RESTORE_EXIT);
}
else {
th->errinfo = ruby_errinfo;