https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112009-07-10T05:28:33ZRuby Issue Tracking SystemRuby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=45472009-07-10T05:28:33Zrunpaint (Run Paint Run Run)runrun@runpaint.org
<ul></ul><p>=begin<br>
('io-reopen2.rb' should be 'io-reopen.rb' in the above examples. :-()<br>
=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=45842009-07-13T20:10:49Zyugui (Yuki Sonoda)yugui@yugui.jp
<ul><li><strong>Target version</strong> set to <i>1.9.2</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=47452009-07-16T15:49:22Zyugui (Yuki Sonoda)yugui@yugui.jp
<ul><li><strong>Assignee</strong> set to <i>nobu (Nobuyoshi Nakada)</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=47542009-07-16T16:07:05Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>=begin<br>
Applied in changeset r24144.<br>
=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=50562009-08-02T16:12:18Zrunpaint (Run Paint Run Run)runrun@runpaint.org
<ul></ul><p>=begin<br>
Thanks, nobu. There's some related oddness, however:</p>
<p>$ echo -e "ant\nalien\n" > a<br>
$ echo -e "bear\nbison\n" > b<br>
$ cat reopen.rb</p>
<p>a = File.open('a')<br>
b = File.open('b')<br>
a.gets<br>
b.reopen(a)<br>
p b.gets</p>
<p>$ ruby -v reopen.rb<br>
ruby 1.9.2dev (2009-08-02 trunk 24352) [i686-linux]<br>
"alien\n"</p>
<p>$ ruby86 -v reopen.rb<br>
ruby 1.8.6 (2009-07-20 patchlevel 381) [i686-linux]<br>
nil</p>
<p>$ cat reopen2.rb<br>
a = File.open('a')<br>
b = File.open('b')<br>
a.reopen(b)<br>
a.gets<br>
a.reopen(b)<br>
p a.gets</p>
<p>$ ruby -v reopen2.rb<br>
ruby 1.9.2dev (2009-08-02 trunk 24352) [i686-linux]<br>
nil</p>
<p>$ ruby86 -v reopen2.rb<br>
ruby 1.8.6 (2009-07-20 patchlevel 381) [i686-linux]<br>
"bear\n"</p>
<p>Also, what are we to do about 1.8 not copying across the #pos? Will r24144 fix that, or shall I open a separate ticket for 1.8?</p>
<p>=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=51102009-08-05T00:51:35Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/24686">[ruby-core:24686]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8 (Closed)" href="https://bugs.ruby-lang.org/issues/1755">#1755</a>] IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8"<br>
on Sun, 2 Aug 2009 16:12:19 +0900, Run Paint Run Run <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> writes:</p>
<p>|Thanks, nobu. There's some related oddness, however:</p>
<p>On your platform, ruby 1.8 seems to copy the position in the stream<br>
when 1.9 don't. 1.8 does simply use dup2 + fdopen, where no standard<br>
define if position information is shared among such file descriptors<br>
or not, as far as I know. So it's up to stdio of the platform. 1.9<br>
implements our own I/O, so we can define the behavior.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=56082009-09-05T04:50:54Zrunpaint (Run Paint Run Run)runrun@runpaint.org
<ul></ul><p>=begin</p>
<blockquote>
<p>On your platform, ruby 1.8 seems to copy the position in the stream<br>
when 1.9 don't. 1.8 does simply use dup2 + fdopen, where no standard<br>
define if position information is shared among such file descriptors<br>
or not, as far as I know. So it's up to stdio of the platform. 1.9<br>
implements our own I/O, so we can define the behavior.</p>
</blockquote>
<p>Apologies for being dense, but does this apply only to copying across the #pos, or to all of the differences I described? IOW, is the behaviour below intentional on 1.9, i.e. by design, or operating-system dependent ("undefined")?</p>
<p>$ cat reopen.rb<br>
File.open('f','w') do |f|<br>
10000.times {|n| f.puts n }<br>
end<br>
a = File.open('f')<br>
b = File.open('f')<br>
a.reopen(b)<br>
a.gets<br>
a.reopen(b)<br>
p a.gets</p>
<p>$ ruby -v reopen.rb<br>
ruby 1.9.2dev (2009-09-03 trunk 24741) [i686-linux]<br>
"60\n"<br>
$ ruby8 -v reopen.rb<br>
ruby 1.8.8dev (2009-09-04) [i686-linux]<br>
"0\n"</p>
<p>=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=74122009-12-23T05:31:25Zujihisa (Tatsuhiro Ujihisa)
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li></ul><p>=begin<br>
The last question from Run Paint Run Run doesn't seem to be answered yet.</p>
<a name="This-issue-is-related-to-2516"></a>
<h1 >This issue is related to <a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Bug: IO#reopen Compatibility (original: <a href="https://blade.ruby-lang.org/ruby-dev/39479">[ruby-dev:39479]</a>) (Rejected)" href="https://bugs.ruby-lang.org/issues/2516">#2516</a><a href="#This-issue-is-related-to-2516" class="wiki-anchor">¶</a></h1>
<a name="httpredmineruby-langorgissuesshow2516"></a>
<h1 ><a href="http://redmine.ruby-lang.org/issues/show/2516" class="external">http://redmine.ruby-lang.org/issues/show/2516</a><a href="#httpredmineruby-langorgissuesshow2516" class="wiki-anchor">¶</a></h1>
<p>=end</p> Ruby master - Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8https://bugs.ruby-lang.org/issues/1755?journal_id=105592010-04-27T21:34:52Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>=begin<br>
Hi,</p>
<p>This weird behavior is caused by buffering. This may be improved in<br>
the future, but at least currently, is not a bug. <a href="https://blade.ruby-lang.org/ruby-core/28335">[ruby-core:28335]</a></p>
<p>To avoid this, I recommend you to avoid IO#reopen. If it is really<br>
needed, use only against IO that has never been read yet.</p>
<p>There is some tickets related to the same reason.<br>
I'll close them and register new ticket to Feature tracker to improve<br>
this issue.</p>
<p>--<br>
Yusue Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a><br>
=end</p>