* process.c (EXEC_OPTION_DUP2_CHILD): defined.

(check_exec_redirect_fd): check :in, :out and :err.
  (check_exec_redirect): check [:child, fd].
  (check_exec_fds): validate EXEC_OPTION_DUP2_CHILD array.
  (run_exec_dup2_child): new function.
  (rb_run_exec_options): call run_exec_dup2_child.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-12-03 15:02:10 +00:00
parent 8c01ec883a
commit 30b8f1ee2b
3 changed files with 154 additions and 19 deletions

View file

@ -415,6 +415,26 @@ class TestProcess < Test::Unit::TestCase
}
end
def test_execopts_redirect_dup2_child
with_tmpchdir {|d|
Process.wait spawn(RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'", STDOUT=>"out", STDERR=>[:child, STDOUT])
assert_equal("errout", File.read("out"))
Process.wait spawn(RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'", STDERR=>"out", STDOUT=>[:child, STDERR])
assert_equal("errout", File.read("out"))
IO.popen([RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'", STDERR=>[:child, STDOUT]]) {|io|
assert_equal("errout", io.read)
}
assert_raise(ArgumentError) {
Process.wait spawn(*TRUECOMMAND, STDOUT=>[:child, STDOUT])
}
assert_raise(ArgumentError) {
Process.wait spawn(*TRUECOMMAND, STDOUT=>[:child, 3])
}
}
end
def test_execopts_exec
with_tmpchdir {|d|
write_file("s", 'exec "echo aaa", STDOUT=>"foo"')