summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-05 13:37:09 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-05 13:37:09 +0000
commit7a69a3583c2235c0ad3ad0705aa2f08cbe2d76bb (patch)
tree25c6c82a0c18f7c08c7d2e101a69901c0ab24702 /process.c
parentedacb3a94ac275a62451f49bb2f70e9c1fc6619b (diff)
* process.c (check_exec_redirect): Open the file in write mode for
redirect from [:out, :err]. Proposed and implemented by Yusuke Endoh. [ruby-dev:41430] [Feature #3348] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/process.c b/process.c
index f35af49..7946b17 100644
--- a/process.c
+++ b/process.c
@@ -1595,7 +1595,19 @@ check_exec_redirect(VALUE key, VALUE val, struct rb_execarg *eargp)
key = check_exec_redirect_fd(key, 1);
if (FIXNUM_P(key) && (FIX2INT(key) == 1 || FIX2INT(key) == 2))
flags = INT2NUM(O_WRONLY|O_CREAT|O_TRUNC);
- else
+ else if (TYPE(key) == T_ARRAY) {
+ int i;
+ for (i = 0; i < RARRAY_LEN(key); i++) {
+ VALUE v = RARRAY_PTR(key)[i];
+ VALUE fd = check_exec_redirect_fd(v, 1);
+ if (FIX2INT(fd) != 1 && FIX2INT(fd) != 2) break;
+ }
+ if (i == RARRAY_LEN(key))
+ flags = INT2NUM(O_WRONLY|O_CREAT|O_TRUNC);
+ else
+ flags = INT2NUM(O_RDONLY);
+ }
+ else
flags = INT2NUM(O_RDONLY);
perm = INT2FIX(0644);
param = hide_obj(rb_ary_new3(3, hide_obj(EXPORT_DUP(path)),