summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-03 13:53:53 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-03 13:53:53 +0000
commit61c148723d128db48196a7f46e9ba2b7e704fc37 (patch)
tree1dc9029efb2af723462686153bb0d85008608131 /process.c
parentcb5217088bfa512c359cbcd5d2ec177590bd13f0 (diff)
* process.c (rb_run_exec_options_err): chdir at last to interpret
relative pathnames from the current directory of the parent process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/process.c b/process.c
index ba7bee19f0..2323195f8f 100644
--- a/process.c
+++ b/process.c
@@ -2367,20 +2367,6 @@ rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char
}
}
- obj = rb_ary_entry(options, EXEC_OPTION_CHDIR);
- if (!NIL_P(obj)) {
- if (!NIL_P(soptions)) {
- char *cwd = my_getcwd();
- rb_ary_store(soptions, EXEC_OPTION_CHDIR,
- hide_obj(rb_str_new2(cwd)));
- xfree(cwd);
- }
- if (chdir(RSTRING_PTR(obj)) == -1) {
- ERRMSG("chdir");
- return -1;
- }
- }
-
obj = rb_ary_entry(options, EXEC_OPTION_UMASK);
if (!NIL_P(obj)) {
mode_t mask = NUM2MODET(obj);
@@ -2424,6 +2410,20 @@ rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char
return -1;
}
+ obj = rb_ary_entry(options, EXEC_OPTION_CHDIR);
+ if (!NIL_P(obj)) {
+ if (!NIL_P(soptions)) {
+ char *cwd = my_getcwd();
+ rb_ary_store(soptions, EXEC_OPTION_CHDIR,
+ hide_obj(rb_str_new2(cwd)));
+ xfree(cwd);
+ }
+ if (chdir(RSTRING_PTR(obj)) == -1) {
+ ERRMSG("chdir");
+ return -1;
+ }
+ }
+
return 0;
}
@@ -3141,8 +3141,6 @@ rb_f_system(int argc, VALUE *argv)
* resource limit: resourcename is core, cpu, data, etc. See Process.setrlimit.
* :rlimit_resourcename => limit
* :rlimit_resourcename => [cur_limit, max_limit]
- * current directory:
- * :chdir => str
* umask:
* :umask => int
* redirection:
@@ -3165,6 +3163,8 @@ rb_f_system(int argc, VALUE *argv)
* io : the file descriptor specified as io.fileno
* file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not
* :close_others => true : don't inherit
+ * current directory:
+ * :chdir => str
*
* If a hash is given as +env+, the environment is
* updated by +env+ before <code>exec(2)</code> in the child process.
@@ -3208,10 +3208,6 @@ rb_f_system(int argc, VALUE *argv)
* pid = spawn(command, :rlimit_core=>max) # enable core dump
* pid = spawn(command, :rlimit_core=>0) # never dump core.
*
- * The <code>:chdir</code> key in +options+ specifies the current directory.
- *
- * pid = spawn(command, :chdir=>"/var/tmp")
- *
* The <code>:umask</code> key in +options+ specifies the umask.
*
* pid = spawn(command, :umask=>077)
@@ -3291,6 +3287,10 @@ rb_f_system(int argc, VALUE *argv)
* io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
* p io.read #=> "out\nerr\n"
*
+ * The <code>:chdir</code> key in +options+ specifies the current directory.
+ *
+ * pid = spawn(command, :chdir=>"/var/tmp")
+ *
* spawn closes all non-standard unspecified descriptors by default.
* The "standard" descriptors are 0, 1 and 2.
* This behavior is specified by :close_others option.