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

ruby-changes:33150

From: akr <ko1@a...>
Date: Sat, 1 Mar 2014 19:56:43 +0900 (JST)
Subject: [ruby-changes:33150] akr:r45229 (trunk): * lib/open3.rb (Open3.capture3): Ignore Errno::EPIPE for writing

akr	2014-03-01 19:56:39 +0900 (Sat, 01 Mar 2014)

  New Revision: 45229

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

  Log:
    * lib/open3.rb (Open3.capture3): Ignore Errno::EPIPE for writing
      stdin_data.
      (Open3.capture2): Ditto.
      (Open3.capture2e): Ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/open3.rb
    trunk/test/test_open3.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45228)
+++ ChangeLog	(revision 45229)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Mar  1 19:51:42 2014  Tanaka Akira  <akr@f...>
+
+	* lib/open3.rb (Open3.capture3): Ignore Errno::EPIPE for writing
+	  stdin_data.
+	  (Open3.capture2): Ditto.
+	  (Open3.capture2e): Ditto.
+
 Sat Mar  1 19:06:47 2014  Eric Wong  <e@8...>
 
 	* gc.c (ruby_gc_set_params): simplify condition
Index: lib/open3.rb
===================================================================
--- lib/open3.rb	(revision 45228)
+++ lib/open3.rb	(revision 45229)
@@ -257,7 +257,10 @@ module Open3 https://github.com/ruby/ruby/blob/trunk/lib/open3.rb#L257
       end
       out_reader = Thread.new { o.read }
       err_reader = Thread.new { e.read }
-      i.write stdin_data
+      begin
+        i.write stdin_data
+      rescue Errno::EPIPE
+      end
       i.close
       [out_reader.value, err_reader.value, t.value]
     }
@@ -300,7 +303,10 @@ module Open3 https://github.com/ruby/ruby/blob/trunk/lib/open3.rb#L303
         o.binmode
       end
       out_reader = Thread.new { o.read }
-      i.write stdin_data
+      begin
+        i.write stdin_data
+      rescue Errno::EPIPE
+      end
       i.close
       [out_reader.value, t.value]
     }
@@ -330,7 +336,10 @@ module Open3 https://github.com/ruby/ruby/blob/trunk/lib/open3.rb#L336
         oe.binmode
       end
       outerr_reader = Thread.new { oe.read }
-      i.write stdin_data
+      begin
+        i.write stdin_data
+      rescue Errno::EPIPE
+      end
       i.close
       [outerr_reader.value, t.value]
     }
Index: test/test_open3.rb
===================================================================
--- test/test_open3.rb	(revision 45228)
+++ test/test_open3.rb	(revision 45229)
@@ -149,6 +149,25 @@ class TestOpen3 < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_open3.rb#L149
     assert(s.success?)
   end
 
+  def test_capture3_stdin_data
+    o, e, s = Open3.capture3(RUBY, '-e', '', :stdin_data=>"z"*(1024*1024))
+    assert_equal("", o)
+    assert_equal("", e)
+    assert(s.success?)
+  end
+
+  def test_capture2_stdin_data
+    o, s = Open3.capture2(RUBY, '-e', '', :stdin_data=>"z"*(1024*1024))
+    assert_equal("", o)
+    assert(s.success?)
+  end
+
+  def test_capture2e_stdin_data
+    oe, s = Open3.capture2e(RUBY, '-e', '', :stdin_data=>"z"*(1024*1024))
+    assert_equal("", oe)
+    assert(s.success?)
+  end
+
   def test_pipeline_rw
     Open3.pipeline_rw([RUBY, '-e', 'print STDIN.read + "1"'],
                       [RUBY, '-e', 'print STDIN.read + "2"']) {|i,o,ts|

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

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