Bug #2796

IO behaviors on mingw

Added by mame (Yusuke Endoh) about 2 years ago. Updated about 1 year ago.

[ruby-dev:40506]
Status:Closed Start date:
Priority:Low Due date:
Assignee:- % Done:

100%

Category:-
Target version:-
ruby -v:

Description

akr さん
遠藤です。

以下のように、IO に関して Linux と mingw で挙動が違います。
それぞれ仕様でしょうか、バグでしょうか。


1) $ ./ruby -e 'f = File.open("foo", "w"); IO.for_fd(f.fileno, "r")'
linux: EINVAL
mingw: 何も言わない (gets したら EBADF)
参考: http://redmine.ruby-lang.org/issues/show/1582


2) $ ./ruby -e 'f1 = File.open("foo", "w"); f2 = IO.new(f1.fileno); p f2.gets'
linux: IOError
mingw: EBADF


3) $ rm foo && touch foo && ./ruby -e 'f = File.open("foo"); p f.eof?;
p f.getc; f.ungetc(100); p f.eof?; p f.getc'
linux: true, nil, false, "d"
mingw: true, nil, true, "d"


4) $ echo foo > foo && ./ruby -e 'f = File.open("foo"); f.getc; p
f.pos; f.ungetc(100); p f.pos'
linux: 1, 0
mingw: 1, 1


5) $ ./ruby -e 'File.open("foo", "w") {|f|
f.write_nonblock("012345678901234567890123456789") }'
linux: 普通に書き込まれる
mingw: EBADF


なんとなく想像できるものもありますが、IO はとても難解なので
下手に判断することをやめます。

-- 
Yusuke ENDOH <mame@tsg.ne.jp>

Related issues

related to ruby-trunk - Bug #1582: IO.new Raises Other Errors between 1.8 and 1.9 Closed 06/06/2009

Associated revisions

Revision 27419
Added by usa (Usaku NAKAMURA) about 2 years ago

* io.c: rdoc. see [ruby-dev:40506].

Revision 27470
Added by akr (Akira Tanaka) about 2 years ago

* io.c: raise IOError when byte oriented operations occur with non-empty character buffer. [ruby-dev:40493] [ruby-dev:40506]

History

Updated by usa (Usaku NAKAMURA) about 2 years ago

こんにちは、なかむら(う)です。

In message "[ruby-dev:40508] Re: [Bug:trunk] IO behaviors on mingw"
    on Feb.27,2010 01:43:30, <akr@fsij.org> wrote:
> 私はテスト環境を持っていないので以下の記述は単なる推測であり、
> 確実な話ではないと考えて読んでください。

1) 2) 5) については田中さんのおっしゃるとおりかと思います。
前2者は将来どうにかするかもしれません。しないかもしれません。


ところで、3) や 4) みたいにテキストモードが絡んでそうな奴は、
テキストモードでオープンすりゃ環境非依存で再現できると思うの
で、mingwとかに話を限定しない再現ケースを作ってバグ登録した方
がいいんじゃないかと思います>遠藤さん


それでは。
-- 
U.Nakamura <usa@garbagecollect.jp>

Updated by akr (Akira Tanaka) about 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
This issue was solved with changeset r27470.
Yusuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

Also available in: Atom PDF