diff --git a/ChangeLog b/ChangeLog index 8e3e207354..761f022180 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Sep 20 17:28:00 2007 Nobuyoshi Nakada + + * io.c (popen_exec), process.c (rb_spawn): stop other threads before + exec. [ruby-core:08262] + Tue Sep 18 22:08:42 2007 Keiju Ishitsuka * lib/matrix.rb: fix a coerce bug of Vector. [ruby-core: 12190] diff --git a/io.c b/io.c index fa63537ab5..944a4f3749 100644 --- a/io.c +++ b/io.c @@ -3110,6 +3110,7 @@ popen_exec(void *pp) struct popen_arg *p = (struct popen_arg*)pp; int fd; + rb_thread_atfork(); popen_redirect(p); for (fd = 3; fd < NOFILE; fd++) { #ifdef FD_CLOEXEC diff --git a/process.c b/process.c index afd59c6ac8..5bceb2be64 100644 --- a/process.c +++ b/process.c @@ -163,7 +163,7 @@ get_pid(void) static VALUE get_ppid(void) { - rb_secure(2); + rb_secure(2); #ifdef _WIN32 return INT2FIX(0); #else @@ -959,7 +959,6 @@ proc_exec_v(char **argv, const char *prog) { if (!prog) prog = argv[0]; - security(prog); prog = dln_find_exe(prog, 0); if (!prog) { errno = ENOENT; @@ -1202,6 +1201,7 @@ rb_check_argv(int argc, VALUE *argv) { VALUE tmp, prog; int i; + const char *name = 0; if (argc == 0) { rb_raise(rb_eArgError, "wrong number of arguments"); @@ -1217,12 +1217,15 @@ rb_check_argv(int argc, VALUE *argv) argv[0] = RARRAY_PTR(tmp)[1]; SafeStringValue(prog); StringValueCStr(prog); + prog = rb_str_new4(prog); + name = RSTRING_PTR(prog); } for (i = 0; i < argc; i++) { SafeStringValue(argv[i]); + argv[i] = rb_str_new4(argv[i]); StringValueCStr(argv[i]); } - security(RSTRING_PTR(prog ? prog : argv[0])); + security(name ? name : RSTRING_PTR(argv[0])); return prog; } @@ -1298,6 +1301,13 @@ rb_exec(const struct rb_exec_arg *e) return -1; } +static int +rb_exec_atfork(void* arg) +{ + rb_thread_atfork(); + return rb_exec(arg); +} + #ifdef HAVE_FORK #ifdef FD_CLOEXEC #if SIZEOF_INT == SIZEOF_LONG @@ -1708,7 +1718,7 @@ rb_spawn(int argc, VALUE *argv) earg.argc = argc; earg.argv = argv; earg.prog = prog ? RSTRING_PTR(prog) : 0; - status = rb_fork(&status, (int (*)(void*))rb_exec, &earg); + status = rb_fork(&status, rb_exec_atfork, &earg); if (prog && argc) argv[0] = prog; } #elif defined HAVE_SPAWNV diff --git a/version.h b/version.h index 6e2892d8ba..5634b8bce8 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2007-09-15" +#define RUBY_RELEASE_DATE "2007-09-20" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20070915 +#define RUBY_RELEASE_CODE 20070920 #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 9 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_DAY 20 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];