Forum: Ruby open file for reading as non block

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5044d0567cc7ae2e52cbd511958e2c15?d=identicon&s=25 Junkone (Guest)
on 2008-10-06 01:48
(Received via mailing list)
how do i open the file for reading as non blocking mode. as you can
see the first 2 attempts do not work.

irb(main):058:0>,File::NONBLOCK + File::RDONLY){|f|}
IOError: not opened for reading
        from (irb):58:in `read'
        from (irb):58
        from (irb):58:in `open'
        from (irb):58
        from ¢¾:0
irb(main):059:0>,File::NONBLOCK ){|f|}
IOError: not opened for reading
        from (irb):59:in `read'
        from (irb):59
        from (irb):59:in `open'
        from (irb):59
        from ¢¾:0
irb(main):060:0>,"r" ){|f|}
=> "test"
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2008-10-06 13:17
(Received via mailing list)
2008/10/5 Junkone <>:
>        from ¢¾:0
Works for me:

irb(main):006:0>"environment", File::RDONLY |
File::NONBLOCK) {|io|}.size
=> 4398

IMHO "|" is better than "+" because it expresses more clearly that
this is about bit masks.

Btw, what do you expect from opening a file nonblocking?  Is there any
other process writing to it?


This topic is locked and can not be replied to.