diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-05 12:21:01 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-05 12:21:01 +0000 |
commit | 025cfde57d14b12504595130cb1b222372881143 (patch) | |
tree | 1b4233c4f6e2f26bce12f1815378457fbc2537ee /process.c | |
parent | 72f2d2a00d8ae3861a15ca92bf9322951a22b6cf (diff) | |
download | ruby-025cfde57d14b12504595130cb1b222372881143.tar.gz |
* eval_thread.c, common.mk: remove eval_thread.c.
* yarvcore.c: rename cYarvThread to rb_cThread.
* gc.c: remove YARV_* prefix.
* gc.h: add an include guard and prototype of rb_gc_set_stack_end().
* inits.c: fix to ANSI prototype style and reorder Init_*().
* io.c (pipe_finalize): TODO: comment out last_status.
* process.c, yarvcore.h: fix to use yarv_vm_t#last_status instead of
rb_last_status and make last_status_get() to access $?.
* yarvcore.c (vm_mark): mark yarv_vm_t#last_status.
* ruby.h: add declarations of rb_cISeq and rb_cVM.
* thread.c: move eval_thread.c codes to thread.c and remove yarv_*
function prefix.
* thread.c (thread_start_func_2): use yarv_thread_t#first_func if
it is not null.
* vm.c: fix copyright year.
* yarvcore.c (Init_vm): rename to Init_VM().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 33 |
1 files changed, 20 insertions, 13 deletions
@@ -14,6 +14,8 @@ #include "ruby.h" #include "rubysig.h" +#include "yarvcore.h" + #include <stdio.h> #include <errno.h> #include <signal.h> @@ -194,16 +196,21 @@ get_ppid(void) */ static VALUE rb_cProcStatus; -VALUE rb_last_status = Qnil; static void last_status_set(int status, int pid) { - rb_last_status = rb_obj_alloc(rb_cProcStatus); - rb_iv_set(rb_last_status, "status", INT2FIX(status)); - rb_iv_set(rb_last_status, "pid", INT2FIX(pid)); + yarv_vm_t *vm = GET_VM(); + vm->last_status = rb_obj_alloc(rb_cProcStatus); + rb_iv_set(vm->last_status, "status", INT2FIX(status)); + rb_iv_set(vm->last_status, "pid", INT2FIX(pid)); } +static VALUE +last_status_get(void) +{ + return GET_VM()->last_status; +} /* * call-seq: @@ -636,7 +643,7 @@ static int waitall_each(int pid, int status, VALUE ary) { last_status_set(status, pid); - rb_ary_push(ary, rb_assoc_new(INT2NUM(pid), rb_last_status)); + rb_ary_push(ary, rb_assoc_new(INT2NUM(pid), GET_VM()->last_status)); return ST_DELETE; } #endif @@ -721,7 +728,7 @@ proc_wait(int argc, VALUE *argv) if ((pid = rb_waitpid(pid, &status, flags)) < 0) rb_sys_fail(0); if (pid == 0) { - return rb_last_status = Qnil; + return GET_VM()->last_status = Qnil; } return INT2FIX(pid); } @@ -749,7 +756,7 @@ proc_wait2(int argc, VALUE *argv) { VALUE pid = proc_wait(argc, argv); if (NIL_P(pid)) return Qnil; - return rb_assoc_new(pid, rb_last_status); + return rb_assoc_new(pid, GET_VM()->last_status); } @@ -798,10 +805,10 @@ proc_waitall(void) rb_sys_fail(0); } last_status_set(status, pid); - rb_ary_push(result, rb_assoc_new(INT2NUM(pid), rb_last_status)); + rb_ary_push(result, rb_assoc_new(INT2NUM(pid), GET_VM()->last_status)); } #else - rb_last_status = Qnil; + GET_VM()->last_status = Qnil; for (pid = -1;;) { pid = rb_waitpid(-1, &status, 0); if (pid == -1) { @@ -809,7 +816,7 @@ proc_waitall(void) break; rb_sys_fail(0); } - rb_ary_push(result, rb_assoc_new(INT2NUM(pid), rb_last_status)); + rb_ary_push(result, rb_assoc_new(INT2NUM(pid), GET_VM()->last_status)); } #endif return result; @@ -822,7 +829,7 @@ detach_process_watcher(int *pid_p) for (;;) { cpid = rb_waitpid(*pid_p, &status, WNOHANG); - if (cpid != 0) return rb_last_status; + if (cpid != 0) return GET_VM()->last_status; rb_thread_sleep(1); } } @@ -1601,7 +1608,7 @@ rb_f_system(int argc, VALUE *argv) if (status < 0) { rb_sys_fail(RSTRING_PTR(argv[0])); } - status = NUM2INT(rb_last_status); + status = NUM2INT(GET_VM()->last_status); if (status == EXIT_SUCCESS) return Qtrue; return Qfalse; } @@ -3593,8 +3600,8 @@ VALUE rb_mProcID_Syscall; void Init_process(void) { + rb_define_virtual_variable("$?", last_status_get, 0); rb_define_virtual_variable("$$", get_pid, 0); - rb_define_readonly_variable("$?", &rb_last_status); rb_define_global_function("exec", rb_f_exec, -1); rb_define_global_function("fork", rb_f_fork, 0); rb_define_global_function("exit!", rb_f_exit_bang, -1); |