summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--include/ruby/io.h1
-rw-r--r--io.c2
-rw-r--r--process.c5
-rw-r--r--test/ruby/test_process.rb14
5 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f9eb34561..e939b7da69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Jul 27 18:25:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (rb_io_check_io): make public.
+
+ * process.c (check_exec_redirect): try conversion to IO on redirect
+ parameters. [ruby-core:44181] [Bug #6269]
+
Fri Jul 27 17:58:12 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (RUBY_CPPOUTFILE): get rid of variable conflict so
diff --git a/include/ruby/io.h b/include/ruby/io.h
index cfdfaf1fb7..07be55c46c 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -168,6 +168,7 @@ void rb_io_synchronized(rb_io_t*);
void rb_io_check_initialized(rb_io_t*);
void rb_io_check_closed(rb_io_t*);
VALUE rb_io_get_io(VALUE io);
+VALUE rb_io_check_io(VALUE io);
VALUE rb_io_get_write_io(VALUE io);
VALUE rb_io_set_write_io(VALUE io, VALUE w);
int rb_io_wait_readable(int);
diff --git a/io.c b/io.c
index 91ab2d8c93..33b609e915 100644
--- a/io.c
+++ b/io.c
@@ -590,7 +590,7 @@ rb_io_get_io(VALUE io)
return rb_convert_type(io, T_FILE, "IO", "to_io");
}
-static VALUE
+VALUE
rb_io_check_io(VALUE io)
{
return rb_check_convert_type(io, T_FILE, "IO", "to_io");
diff --git a/process.c b/process.c
index 3aacc5d60b..16e6e6a568 100644
--- a/process.c
+++ b/process.c
@@ -1456,6 +1456,7 @@ check_exec_redirect(VALUE key, VALUE val, struct rb_execarg *eargp)
{
VALUE param;
VALUE path, flags, perm;
+ VALUE tmp;
ID id;
switch (TYPE(val)) {
@@ -1484,6 +1485,7 @@ check_exec_redirect(VALUE key, VALUE val, struct rb_execarg *eargp)
break;
case T_FILE:
+ io:
val = check_exec_redirect_fd(val, 0);
/* fall through */
case T_FIXNUM:
@@ -1531,6 +1533,9 @@ check_exec_redirect(VALUE key, VALUE val, struct rb_execarg *eargp)
break;
default:
+ tmp = val;
+ val = rb_io_check_io(tmp);
+ if (!NIL_P(val)) goto io;
rb_raise(rb_eArgError, "wrong exec redirect action");
}
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 26073db089..a34da82d5b 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -1,5 +1,5 @@
require 'test/unit'
-require 'tmpdir'
+require 'tempfile'
require 'pathname'
require 'timeout'
require_relative 'envutil'
@@ -806,6 +806,18 @@ class TestProcess < Test::Unit::TestCase
end
end
+ def test_execopts_redirect_tempfile
+ bug6269 = '[ruby-core:44181]'
+ Tempfile.open("execopts") do |tmp|
+ pid = assert_nothing_raised(ArgumentError, bug6269) do
+ break spawn(RUBY, "-e", "print $$", out: tmp)
+ end
+ Process.wait(pid)
+ tmp.rewind
+ assert_equal(pid.to_s, tmp.read)
+ end
+ end
+
def test_execopts_duplex_io
IO.popen("#{RUBY} -e ''", "r+") {|duplex|
assert_raise(ArgumentError) { system("#{RUBY} -e ''", duplex=>STDOUT) }