diff --git a/ChangeLog b/ChangeLog index 801ac5d40b..5bd8c35d01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Aug 29 23:42:59 2012 Tanaka Akira + + * internal.h (rb_last_status_clear): declared. + + * process.c (rb_last_status_clear): exported. + (rb_f_system): call rb_last_status_clear. + + * io.c (rb_f_backquote): call rb_last_status_clear. + Wed Aug 29 22:01:15 2012 Tanaka Akira * process.c (rb_f_system): check failures of waitpid. diff --git a/internal.h b/internal.h index ed4864c1eb..57c1fc8cfa 100644 --- a/internal.h +++ b/internal.h @@ -222,6 +222,7 @@ struct rb_execarg { #define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1) rb_pid_t rb_fork_ruby(int *status); +void rb_last_status_clear(void); /* rational.c */ VALUE rb_lcm(VALUE x, VALUE y); diff --git a/io.c b/io.c index b1a38cc707..4b6851b44d 100644 --- a/io.c +++ b/io.c @@ -7808,6 +7808,7 @@ rb_f_backquote(VALUE obj, VALUE str) rb_io_t *fptr; SafeStringValue(str); + rb_last_status_clear(); port = pipe_open_s(str, "r", FMODE_READABLE|DEFAULT_TEXTMODE, NULL); if (NIL_P(port)) return rb_str_new(0,0); diff --git a/process.c b/process.c index 25eed71a4e..e0bb84a4d2 100644 --- a/process.c +++ b/process.c @@ -226,7 +226,7 @@ rb_last_status_set(int status, rb_pid_t pid) rb_iv_set(th->last_status, "pid", PIDT2NUM(pid)); } -static void +void rb_last_status_clear(void) { GET_THREAD()->last_status = Qnil; @@ -3656,6 +3656,7 @@ rb_f_system(int argc, VALUE *argv) #ifdef SIGCHLD RETSIGTYPE (*chfunc)(int); + rb_last_status_clear(); chfunc = signal(SIGCHLD, SIG_DFL); #endif pid = rb_spawn_internal(argc, argv, NULL, 0);