https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112020-09-10T18:27:30ZRuby Issue Tracking SystemRuby master - Bug #14434: IO#reopen fails after EPIPEhttps://redmine.ruby-lang.org/issues/14434?journal_id=875222020-09-10T18:27:30Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>I tried updating this patch for the current master branch, but it breaks <code>test_reopen_inherit</code>:</p>
<pre><code> 1) Failure:
TestIO#test_reopen_inherit [/ruby/test/ruby/test_io.rb:2385]:
<"outerr"> expected but was
<"">.
</code></pre>
<p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/4">@nobu (Nobuyoshi Nakada)</a>, do you think there is a better way to fix this? I'm not sure the current behavior is a bug, if the pipe is broken, it seems reasonable for <code>IO#reopen</code> to raise an exception.</p>
<p>Here's the patch I used:</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/io.c b/io.c
index 0d6e217857..e41ca74db7 100644
</span><span class="gd">--- a/io.c
</span><span class="gi">+++ b/io.c
</span><span class="p">@@ -7372,8 +7372,7 @@</span> io_reopen(VALUE io, VALUE nfile)
}
}
if (fptr->mode & FMODE_WRITABLE) {
<span class="gd">- if (io_fflush(fptr) < 0)
- rb_sys_fail_on_write(fptr);
</span><span class="gi">+ fptr_finalize_flush(fptr, TRUE, FALSE, 0);
</span> }
else {
flush_before_seek(fptr);
<span class="p">@@ -7399,7 +7398,8 @@</span> io_reopen(VALUE io, VALUE nfile)
if (fd != fd2) {
if (IS_PREP_STDIO(fptr) || fd <= 2 || !fptr->stdio_file) {
/* need to keep FILE objects of stdin, stdout and stderr */
<span class="gd">- if (rb_cloexec_dup2(fd2, fd) < 0)
</span><span class="gi">+ fd = (fd < 0) ? rb_cloexec_dup(fd2) : rb_cloexec_dup2(fd2, fd);
+ if (fd < 0)
</span> rb_sys_fail_path(orig->pathv);
rb_update_max_fd(fd);
}
</code></pre> Ruby master - Bug #14434: IO#reopen fails after EPIPEhttps://redmine.ruby-lang.org/issues/14434?journal_id=951932021-12-07T06:18:07Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>I think this is a bug definitely, but non-critical.</p> Ruby master - Bug #14434: IO#reopen fails after EPIPEhttps://redmine.ruby-lang.org/issues/14434?journal_id=978892022-06-09T05:33:16Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>I asked <a class="user active user-mention" href="https://redmine.ruby-lang.org/users/4">@nobu (Nobuyoshi Nakada)</a> about the current status of this ticket, and he said "the current behavior is definitely a bug, but I am not able to think of a good way to fix it now." I'd like to set this as feedback for a good fix.</p>