diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-11-27 09:23:38 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-11-27 09:23:38 +0000 |
commit | f54418b71f57e00d4a50bd86bf7d18b8b5195287 (patch) | |
tree | d5bd57142a0d4736fdfd1f35dcd864ac40cfb045 /process.c | |
parent | 1f297b8bfc0fdacb8cfb19736cf224b2550281b3 (diff) |
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 31 |
1 files changed, 29 insertions, 2 deletions
@@ -217,7 +217,10 @@ proc_waitpid(argc, argv) if ((pid = rb_waitpid(NUM2INT(vpid), flags, &status)) < 0) rb_sys_fail(0); - if (pid == 0) return Qnil; + if (pid == 0) { + rb_last_status = Qnil; + return Qnil; + } return INT2FIX(pid); } @@ -227,6 +230,7 @@ proc_waitpid2(argc, argv) VALUE *argv; { VALUE pid = proc_waitpid(argc, argv); + if (NIL_P(pid)) return Qnil; return rb_assoc_new(pid, rb_last_status); } @@ -527,6 +531,21 @@ rb_f_exec(argc, argv) } static VALUE +fork_rescue(data, errinfo) + VALUE data, errinfo; +{ + int status = 1; + + if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) { + VALUE st = rb_iv_get(errinfo, "status"); + + status = NUM2INT(st); + } + ruby_finalize(); + _exit(status); +} + +static VALUE rb_f_fork(obj) VALUE obj; { @@ -539,9 +558,17 @@ rb_f_fork(obj) #ifdef linux after_exec(); #endif + rb_thread_atfork(); if (rb_block_given_p()) { - rb_yield(Qnil); +#if 0 + rb_rescue2(rb_yield, Qnil, fork_rescue, 0, rb_eException, 0); _exit(0); +#else + int status; + + rb_protect(rb_yield, Qnil, &status); + ruby_stop(status); +#endif } return Qnil; |