summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-20 08:28:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-20 08:28:03 +0000
commitbf6575ef62b4521d6c1d45371372dc1c1e74f18e (patch)
treeddffa8580a98a94b29e52c079e8d5905ab9cc1ff /process.c
parentee9e5a6ea87fb0365a939639d027ade3eee93cb1 (diff)
* io.c (popen_exec), process.c (rb_spawn): stop other threads before
exec. [ruby-core:08262] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c18
1 files changed, 14 insertions, 4 deletions
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