https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782012-11-17T10:39:27ZRuby Issue Tracking SystemBackport193 - Backport #7358: Wrong fd redirection on forkhttps://bugs.ruby-lang.org/issues/7358?journal_id=330052012-11-17T10:39:27Zdrbrain (Eric Hodel)drbrain@segment7.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>=begin<br>
If you want data to show up in ((%/tmp/foo%)), redirect stdout in the child process. Setting file descriptor 3 does nothing since ((%echo%)) makes no use of it.</p>
<p>#!/usr/bin/env ruby</p>
<p>tmp = File.new('/tmp/foo', File::CREAT | File::WRONLY)<br>
cmd = ['echo', 'yes']</p>
<p>pid = Process.spawn(*cmd, out: tmp)<br>
Process.wait(pid)</p>
<p>pid = fork do<br>
Process.exec(*cmd, close_others: true, out: tmp)<br>
end<br>
Process.wait(pid)<br>
=end</p> Backport193 - Backport #7358: Wrong fd redirection on forkhttps://bugs.ruby-lang.org/issues/7358?journal_id=415932013-09-04T10:35:20Zfelipec (Felipe Contreras)felipe.contreras@gmail.com
<ul></ul><p>That's not what I want, and yes, setting that does nothing, or <em>should</em> do nothing, but that's not what the command above did, it failed.</p>
<p>Fortunately it seems to be fixed now.</p> Backport193 - Backport #7358: Wrong fd redirection on forkhttps://bugs.ruby-lang.org/issues/7358?journal_id=416792013-09-08T16:23:02Zfelipec (Felipe Contreras)felipe.contreras@gmail.com
<ul></ul><p>felipec (Felipe Contreras) wrote:</p>
<blockquote>
<p>That's not what I want, and yes, setting that does nothing, or <em>should</em> do nothing, but that's not what the command above did, it failed.</p>
<p>Fortunately it seems to be fixed now.</p>
</blockquote>
<p>Actually, I went down to bisect where the problem was fixed, and I found it:</p>
<p><a href="https://github.com/ruby/ruby/commit/2fb032b74be9f306fbd2f95d85f8352f4a6027d6" class="external">https://github.com/ruby/ruby/commit/2fb032b74be9f306fbd2f95d85f8352f4a6027d6</a></p>
<p>So it turns out it's fixed in Ruby v2.0, but not v1.9, so this is not "rejected", it should be "already fixed in v2.0", and maybe you would want to backport the fix.</p>
<p>FTR. This is the error I get before the patch:</p>
<p>yes<br>
[ASYNC BUG] consume_communication_pipe: read</p>
<p>EBADF</p>
<p>ruby 2.0.0dev (2012-06-09 trunk 35968) [x86_64-linux]</p>
<p>[NOTE]<br>
You may have encountered a bug in the Ruby interpreter or extension libraries.<br>
Bug reports are welcome.<br>
For details: <a href="http://www.ruby-lang.org/bugreport.html" class="external">http://www.ruby-lang.org/bugreport.html</a></p> Backport193 - Backport #7358: Wrong fd redirection on forkhttps://bugs.ruby-lang.org/issues/7358?journal_id=416802013-09-08T21:27:13Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Backport</i></li><li><strong>Project</strong> changed from <i>Ruby master</i> to <i>Backport193</i></li><li><strong>Status</strong> changed from <i>Rejected</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>usa (Usaku NAKAMURA)</i></li></ul> Backport193 - Backport #7358: Wrong fd redirection on forkhttps://bugs.ruby-lang.org/issues/7358?journal_id=674352017-10-21T12:04:54Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Rejected</i></li></ul><p>1.9.3 is out of date</p> Backport193 - Backport #7358: Wrong fd redirection on forkhttps://bugs.ruby-lang.org/issues/7358?journal_id=675612017-10-24T01:51:38Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p><a href="mailto:usa@garbagecollect.jp" class="email">usa@garbagecollect.jp</a> wrote:</p>
<blockquote>
<p>Status changed from Assigned to Rejected</p>
<p>1.9.3 is out of date</p>
<hr>
<p>Backport <a class="issue tracker-4 status-6 priority-4 priority-default closed" title="Backport: Wrong fd redirection on fork (Rejected)" href="https://bugs.ruby-lang.org/issues/7358">#7358</a>: Wrong fd redirection on fork<br>
<a href="https://bugs.ruby-lang.org/issues/7358#change-67435" class="external">https://bugs.ruby-lang.org/issues/7358#change-67435</a></p>
</blockquote>
<p>I think we actually fixed this for 2.3 around July/August 2015<br>
after I made r51146 to add a new test. That snowballed into a<br>
bunch of subsequent commits to fix things that summer :)</p>