aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-03 11:12:20 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-03 11:12:20 +0000
commit033e2187c65918ee051553b57be9924878b3fda5 (patch)
tree2ba4b11793784b511bd45a0ed027eed5c59fef9b /process.c
parent190d319dab5184b1ef6ecb5df334f6345553b904 (diff)
downloadruby-033e2187c65918ee051553b57be9924878b3fda5.tar.gz
* process.c (rb_proc_exec_e): extended version of rb_proc_exec() to
call execle(). (rb_proc_exec): use rb_proc_exec_e(). (rb_exec_err): use rb_proc_exec_e(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/process.c b/process.c
index ca8efe90c5..2a3a81f5ff 100644
--- a/process.c
+++ b/process.c
@@ -1160,14 +1160,14 @@ rb_proc_exec_n(int argc, VALUE *argv, const char *prog)
}
#ifdef __native_client__
-int
-rb_proc_exec(const char *str)
+static int
+rb_proc_exec_e(const char *str, VALUE envp_str)
{
rb_notimplement();
}
#else
-int
-rb_proc_exec(const char *str)
+static int
+rb_proc_exec_e(const char *str, VALUE envp_str)
{
#ifndef _WIN32
const char *s = str;
@@ -1210,7 +1210,10 @@ rb_proc_exec(const char *str)
exit(status);
#else
before_exec();
- execl("/bin/sh", "sh", "-c", str, (char *)NULL);
+ if (envp_str)
+ execle("/bin/sh", "sh", "-c", str, (char *)NULL, (char **)RSTRING_PTR(envp_str));
+ else
+ execl("/bin/sh", "sh", "-c", str, (char *)NULL);
preserving_errno(after_exec());
#endif
return -1;
@@ -1226,7 +1229,7 @@ rb_proc_exec(const char *str)
*a = NULL;
}
if (argv[0]) {
- ret = proc_exec_v(argv, NULL, Qfalse);
+ ret = proc_exec_v(argv, NULL, envp_str);
}
else {
errno = ENOENT;
@@ -1237,6 +1240,12 @@ rb_proc_exec(const char *str)
}
#endif
+int
+rb_proc_exec(const char *str)
+{
+ return rb_proc_exec_e(str, Qfalse);
+}
+
enum {
EXEC_OPTION_PGROUP,
EXEC_OPTION_RLIMIT,
@@ -2527,7 +2536,7 @@ rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
}
if (argc == 0) {
- rb_proc_exec(prog);
+ rb_proc_exec_e(prog, e->envp_str);
}
else {
rb_proc_exec_ne(argc, argv, prog, e->envp_str);