https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782014-06-15T10:13:00ZRuby Issue Tracking SystemRuby master - Bug #9944: in ruby for windows in "system" a redirection to append a file works incorrectlyhttps://bugs.ruby-lang.org/issues/9944?journal_id=472332014-06-15T10:13:00Zphasis68 (Heesob Park)phasis@gmail.com
<ul></ul><p>If this is a Windows specific issue, here is a patch:</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/process.c b/process.c
index e626542..05bb79c 100644
</span><span class="gd">--- a/process.c
</span><span class="gi">+++ b/process.c
</span><span class="p">@@ -2767,6 +2767,11 @@</span> run_exec_open(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_b
ERRMSG("dup2");
return -1;
}
<span class="gi">+#ifdef _WIN32
+ if (flags & O_APPEND) {
+ lseek(fd, 0L, SEEK_END);
+ }
+#endif
</span> rb_update_max_fd(fd);
}
i++;
</code></pre> Ruby master - Bug #9944: in ruby for windows in "system" a redirection to append a file works incorrectlyhttps://bugs.ruby-lang.org/issues/9944?journal_id=472392014-06-16T07:05:28Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/47239/diff?detail_id=34091">diff</a>)</li><li><strong>Category</strong> set to <i>platform/windows</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>windows</i></li><li><strong>Target version</strong> set to <i>2.2.0</i></li><li><strong>Backport</strong> changed from <i>2.0.0: UNKNOWN, 2.1: UNKNOWN</i> to <i>2.0.0: REQUIRED, 2.1: REQUIRED</i></li></ul><p>Yes, it is Windows specific, because <code>O_APPEND</code> is not supported by the system, but implemented in runtime libraries.<br>
And "appending" and "seeking to the end at first" are not same.</p>
<p>This is a known issue, as commented in test/ruby/test_process.rb:<code>test_execopts_redirect</code>,</p>
<pre><code class="ruby syntaxhl" data-language="ruby"> <span class="k">if</span> <span class="n">windows?</span>
<span class="c1"># currently telling to child the file modes is not supported.</span>
</code></pre>
<p>It is impossible to emulate it completely with multi-process, without the system support.<br>
For example,</p>
<pre><code>$ echo foobar > t; ruby -e 'system("cat", in:["t", "a+"])'
</code></pre>
<p>should show "foobar" now including Windows, but it will be empty with your patch.</p>
<p>Let us consider...</p> Ruby master - Bug #9944: in ruby for windows in "system" a redirection to append a file works incorrectlyhttps://bugs.ruby-lang.org/issues/9944?journal_id=692902018-01-05T21:00:27Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.2.0</i></del>)</li></ul> Ruby master - Bug #9944: in ruby for windows in "system" a redirection to append a file works incorrectlyhttps://bugs.ruby-lang.org/issues/9944?journal_id=1033612023-05-30T22:43:41Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Rejected</i></li></ul><p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/286">@headius (Charles Nutter)</a> and I discussed this on the train back from RubyKaigi and determined this is a Windows-specific limitation, not a Ruby bug, and nothing Ruby does can fix the issue in all cases.</p>