aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-05 16:22:38 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-05 16:22:38 +0000
commit27172b8e6fcd14f07fa5ea5be803cb04bde04559 (patch)
tree38c4e091c97426157118d2eaf8d5d6c0edbabf17
parent48002b881e49ff76f869e0f383fd5419cbca9af3 (diff)
downloadruby-27172b8e6fcd14f07fa5ea5be803cb04bde04559.tar.gz
* 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
-rw-r--r--ChangeLog13
-rw-r--r--ext/pty/pty.c3
-rw-r--r--intern.h2
-rw-r--r--io.c2
-rw-r--r--process.c26
-rw-r--r--version.h6
-rw-r--r--win32/win32.c4
7 files changed, 34 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 029a9711dd..2aa3a10d3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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().
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 215f2cfd6d..5d86525daa 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -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);
}
diff --git a/intern.h b/intern.h
index b3fd3cb0ce..c4a0c2c042 100644
--- a/intern.h
+++ b/intern.h
@@ -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;
diff --git a/io.c b/io.c
index 66203cdbbf..d4885080d1 100644
--- a/io.c
+++ b/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
diff --git a/process.c b/process.c
index ed975dbbb1..ea9347072c 100644
--- a/process.c
+++ b/process.c
@@ -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);
diff --git a/version.h b/version.h
index 99b18b9c96..9502406047 100644
--- a/version.h
+++ b/version.h
@@ -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[];
diff --git a/win32/win32.c b/win32/win32.c
index c3702c10b7..c4aabf62b7 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -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: