* intern.h: prepare rb_last_status_get() and rb_last_status_set().

Use these functions instead of rb_last_status ([ruby-dev:30264]).
* process.c: define above functions.
* ext/pty/pty.c: use above functins.
* io.c (pipe_finalize): ditto.
* process.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-02-05 16:22:38 +00:00
Родитель 48002b881e
Коммит 27172b8e6f
7 изменённых файлов: 34 добавлений и 22 удалений

Просмотреть файл

@ -1,3 +1,16 @@
Tue Feb 6 01:07:14 2007 Koichi Sasada <ko1@atdot.net>
* intern.h: prepare rb_last_status_get() and rb_last_status_set().
Use these functions instead of rb_last_status ([ruby-dev:30264]).
* process.c: define above functions.
* ext/pty/pty.c: use above functins.
* io.c (pipe_finalize): ditto.
* process.c: ditto.
Mon Feb 5 21:26:56 2007 Koichi Sasada <ko1@atdot.net>
* ruby.h: add a prototype of rb_id2str().

Просмотреть файл

@ -135,13 +135,12 @@ struct pty_info {
static void
raise_from_wait(char *state, struct pty_info *info)
{
extern VALUE rb_last_status;
char buf[1024];
VALUE exc;
snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)info->child_pid);
exc = rb_exc_new2(eChildExited, buf);
rb_iv_set(exc, "status", rb_last_status);
rb_iv_set(exc, "status", rb_last_status_get());
rb_funcall(info->thread, rb_intern("raise"), 1, exc);
}

Просмотреть файл

@ -413,6 +413,8 @@ VALUE rb_sym_all_symbols(void);
ID rb_compose_ivar2(ID, VALUE);
ID rb_decompose_ivar2(ID, VALUE*);
/* process.c */
void rb_last_status_set(int status, rb_pid_t pid);
VALUE rb_last_status_get(void);
struct rb_exec_arg {
int argc;
VALUE *argv;

2
io.c
Просмотреть файл

@ -2979,7 +2979,7 @@ pipe_finalize(OpenFile *fptr, int noraise)
#if defined DJGPP
status <<= 8;
#endif
/* TODO: need it? -> rb_last_status = INT2FIX(status); */
rb_last_status_set(status, fptr->pid);
#else
fptr_finalize(fptr, noraise);
#endif

Просмотреть файл

@ -197,8 +197,8 @@ get_ppid(void)
static VALUE rb_cProcStatus;
static void
last_status_set(int status, int pid)
void
rb_last_status_set(int status, rb_pid_t pid)
{
yarv_vm_t *vm = GET_VM();
vm->last_status = rb_obj_alloc(rb_cProcStatus);
@ -206,8 +206,8 @@ last_status_set(int status, int pid)
rb_iv_set(vm->last_status, "pid", INT2FIX(pid));
}
static VALUE
last_status_get(void)
VALUE
rb_last_status_get(void)
{
return GET_VM()->last_status;
}
@ -588,7 +588,7 @@ rb_waitpid(int pid, int *st, int flags)
}
#else /* NO_WAITPID */
if (pid_tbl && st_lookup(pid_tbl, pid, (st_data_t *)st)) {
last_status_set(*st, pid);
rb_last_status_set(*st, pid);
st_delete(pid_tbl, (st_data_t*)&pid, NULL);
return pid;
}
@ -618,7 +618,7 @@ rb_waitpid(int pid, int *st, int flags)
}
#endif
if (result > 0) {
last_status_set(*st, result);
rb_last_status_set(*st, result);
}
return result;
}
@ -642,7 +642,7 @@ wait_each(int pid, int status, struct wait_data *data)
static int
waitall_each(int pid, int status, VALUE ary)
{
last_status_set(status, pid);
rb_last_status_set(status, pid);
rb_ary_push(ary, rb_assoc_new(INT2NUM(pid), GET_VM()->last_status));
return ST_DELETE;
}
@ -804,7 +804,7 @@ proc_waitall(void)
}
rb_sys_fail(0);
}
last_status_set(status, pid);
rb_last_status_set(status, pid);
rb_ary_push(result, rb_assoc_new(INT2NUM(pid), GET_VM()->last_status));
}
#else
@ -1103,7 +1103,7 @@ proc_spawn_v(char **argv, char *prog)
#endif
before_exec();
status = spawnv(P_WAIT, prog, argv);
last_status_set(status == -1 ? 127 : status, 0);
rb_last_status_set(status == -1 ? 127 : status, 0);
after_exec();
return status;
}
@ -1140,7 +1140,7 @@ proc_spawn(char *str)
char *shell = dln_find_exe("sh", 0);
before_exec();
status = shell?spawnl(P_WAIT,shell,"sh","-c",str,(char*)NULL):system(str);
last_status_set(status == -1 ? 127 : status, 0);
rb_last_status_set(status == -1 ? 127 : status, 0);
after_exec();
return status;
}
@ -1557,9 +1557,9 @@ rb_spawn(int argc, VALUE *argv)
if (argc) prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
status = system(StringValuePtr(prog));
# if defined(__human68k__) || defined(__DJGPP__)
last_status_set(status == -1 ? 127 : status, 0);
rb_last_status_set(status == -1 ? 127 : status, 0);
# else
last_status_set((status & 0xff) << 8, 0);
rb_last_status_set((status & 0xff) << 8, 0);
# endif
#endif
return status;
@ -3600,7 +3600,7 @@ VALUE rb_mProcID_Syscall;
void
Init_process(void)
{
rb_define_virtual_variable("$?", last_status_get, 0);
rb_define_virtual_variable("$?", rb_last_status_get, 0);
rb_define_virtual_variable("$$", get_pid, 0);
rb_define_global_function("exec", rb_f_exec, -1);
rb_define_global_function("fork", rb_f_fork, 0);

Просмотреть файл

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-02-05"
#define RUBY_RELEASE_DATE "2007-02-06"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20070205
#define RUBY_RELEASE_CODE 20070206
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 2
#define RUBY_RELEASE_DAY 5
#define RUBY_RELEASE_DAY 6
RUBY_EXTERN const char ruby_version[];
RUBY_EXTERN const char ruby_release_date[];

Просмотреть файл

@ -837,8 +837,6 @@ rb_w32_pipe_exec(const char *cmd, const char *prog, int mode, int *pipe)
return ret;
}
extern VALUE rb_last_status;
int
rb_w32_spawn(int mode, const char *cmd, const char *prog)
{
@ -863,7 +861,7 @@ rb_w32_spawn(int mode, const char *cmd, const char *prog)
switch (mode) {
case P_WAIT:
rb_syswait(child->pid);
return NUM2INT(rb_last_status);
return NUM2INT(rb_last_status_get());
case P_NOWAIT:
return child->pid;
case P_OVERLAY: