Issue #3348 has been updated by Yui NARUSE.

Status changed from Open to Assigned
Assignee set to Akira Tanaka
Target version set to 1.9.x
ruby -v set to 1.9


----------------------------------------
Bug #3348: rubyspec: Kernel.spawn redirects both STDERR and STDOUT  to the given name ERROR
http://redmine.ruby-lang.org/issues/3348

Author: Yusuke Endoh
Status: Assigned
Priority: Low
Assignee: Akira Tanaka
Category: 
Target version: 1.9.x
ruby -v: 1.9


=begin
 ???????????
 
 spawn ??????????????????? :out => "foo" ?????????????????????? foo ???????
 ???????????????????????????????[:out, :err] => "foo" ????????????????????????
 
   ruby -e 'pid = spawn("echo", "foo", [:out, :err] => "foo"); Proces.wait pid'
 
 ?????????????????????????????
 ??????????????????????rubyspec ???????????????????????失??????????????????????????????
 
 ????????中?????????? :out ??? :err ?????????? O_CREAT|O_TRUNC ???????????????????????
 ???対??????????????????????????????
 
 
 diff --git a/process.c b/process.c
 index 9e52392..4ca6ed3 100644
 --- a/process.c
 +++ b/process.c
 @@ -1342,7 +1342,19 @@ check_exec_redirect(VALUE key, VALUE val, VALUE options)
              key = check_exec_redirect_fd(key);
          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);
 +		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(rb_str_dup(path)),
 
 -- 
 Yusuke Endoh <mame / tsg.ne.jp>
=end



-- 
http://redmine.ruby-lang.org