[前][次][番号順一覧][スレッド一覧]

ruby-changes:24500

From: nobu <ko1@a...>
Date: Fri, 27 Jul 2012 18:26:10 +0900 (JST)
Subject: [ruby-changes:24500] nobu:r36551 (trunk): process.c: try conversion at redirection

nobu	2012-07-27 18:25:54 +0900 (Fri, 27 Jul 2012)

  New Revision: 36551

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36551

  Log:
    process.c: try conversion at redirection
    
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/io.h
    trunk/io.c
    trunk/process.c
    trunk/test/ruby/test_process.rb

Index: include/ruby/io.h
===================================================================
--- include/ruby/io.h	(revision 36550)
+++ include/ruby/io.h	(revision 36551)
@@ -168,6 +168,7 @@
 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);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36550)
+++ ChangeLog	(revision 36551)
@@ -1,3 +1,10 @@
+Fri Jul 27 18:25:51 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* configure.in (RUBY_CPPOUTFILE): get rid of variable conflict so
Index: io.c
===================================================================
--- io.c	(revision 36550)
+++ io.c	(revision 36551)
@@ -590,7 +590,7 @@
     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");
Index: process.c
===================================================================
--- process.c	(revision 36550)
+++ process.c	(revision 36551)
@@ -1456,6 +1456,7 @@
 {
     VALUE param;
     VALUE path, flags, perm;
+    VALUE tmp;
     ID id;
 
     switch (TYPE(val)) {
@@ -1484,6 +1485,7 @@
         break;
 
       case T_FILE:
+      io:
         val = check_exec_redirect_fd(val, 0);
         /* fall through */
       case T_FIXNUM:
@@ -1531,6 +1533,9 @@
         break;
 
       default:
+	tmp = val;
+	val = rb_io_check_io(tmp);
+	if (!NIL_P(val)) goto io;
         rb_raise(rb_eArgError, "wrong exec redirect action");
     }
 
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 36550)
+++ test/ruby/test_process.rb	(revision 36551)
@@ -1,5 +1,5 @@
 require 'test/unit'
-require 'tmpdir'
+require 'tempfile'
 require 'pathname'
 require 'timeout'
 require_relative 'envutil'
@@ -806,6 +806,18 @@
     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) }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]