summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-12 16:56:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-12 16:56:06 +0000
commit167553dd4af4605b228c3b061a29c7be920db683 (patch)
tree356b9a30124e0d1344837717aba71d50ed4b49f3 /eval.c
parentdab5357c7cbe9346446db738aeb89c50c9ee7ae7 (diff)
downloadruby-167553dd4af4605b228c3b061a29c7be920db683.tar.gz
ruby-167553dd4af4605b228c3b061a29c7be920db683.tar.xz
ruby-167553dd4af4605b228c3b061a29c7be920db683.zip
* signal.c (sigexit): call rb_thread_signal_exit() instead of
rb_exit(). [ruby-dev:26347] * eval.c (rb_thread_signal_exit): a new function to exit on main thread. * eval.c (rb_thread_switch): exit status should be retrieved from ruby_errinfo. * eval.c (rb_f_exit): ensure exit(0) should call exit(EXIT_SUCCESS). * missing/mkdir.c: remove. [ruby-core:05177] * hash.c (env_aset): do not treat nil as key-removing value. [ruby-list:40865] * parse.y (method_call): allow aref expression ([]) to take a block. * parse.y (block_dup_check): a function to check duplication of a block argument and an actual block. * lib/delegate.rb (SimpleDelegator::__setobj__): need check for recursive delegation. [ruby-core:04940] * lib/cgi.rb: add underscore aliases CGI::escape_html, CGI::unescape_html, CGI::escape_element, CGI::unescape_element. [ruby-core:05058] * misc/ruby-mode.el (ruby-expr-beg): fix looking point drift. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@8613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/eval.c b/eval.c
index ce82e6c8e..0fbc538c7 100644
--- a/eval.c
+++ b/eval.c
@@ -1393,6 +1393,14 @@ static VALUE exception_error;
static VALUE sysstack_error;
static int
+sysexit_status(err)
+ VALUE err;
+{
+ VALUE st = rb_iv_get(err, "status");
+ return NUM2INT(st);
+}
+
+static int
error_handle(ex)
int ex;
{
@@ -1438,8 +1446,7 @@ error_handle(ex)
case TAG_RAISE:
case TAG_FATAL:
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
- VALUE st = rb_iv_get(ruby_errinfo, "status");
- status = NUM2INT(st);
+ status = sysexit_status(ruby_errinfo);
}
else {
error_print();
@@ -4386,6 +4393,9 @@ rb_f_exit(argc, argv)
break;
default:
istatus = NUM2INT(status);
+#if EXIT_SUCCESS != 0
+ if (istatus == 0) istatus = EXIT_SUCCESS;
+#endif
break;
}
}
@@ -10383,8 +10393,7 @@ rb_thread_switch(n)
case RESTORE_EXIT:
ruby_errinfo = th_raise_exception;
ruby_current_node = th_raise_node;
- error_print();
- terminate_process(EXIT_FAILURE, 0, 0);
+ terminate_process(sysexit_status(ruby_errinfo), 0, 0);
break;
case RESTORE_NORMAL:
default:
@@ -12464,6 +12473,28 @@ rb_thread_trap_eval(cmd, sig, safe)
rb_thread_restore_context(curr_thread, RESTORE_TRAP);
}
+void
+rb_thread_signal_exit()
+{
+ VALUE args[2];
+
+ rb_thread_critical = 0;
+ if (curr_thread == main_thread) {
+ rb_thread_ready(curr_thread);
+ rb_exit(EXIT_SUCCESS);
+ }
+ args[0] = INT2NUM(EXIT_SUCCESS);
+ args[1] = rb_str_new2("exit");
+ rb_thread_ready(main_thread);
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return;
+ }
+ }
+ rb_thread_main_jump(rb_class_new_instance(2, args, rb_eSystemExit),
+ RESTORE_EXIT);
+}
+
static VALUE
rb_thread_raise(argc, argv, th)
int argc;