From: Roger Pack Date: 2009-11-17T05:04:20+09:00 Subject: Re: Errno::ENOMEM reading a device in Ruby, not in Java thou > |irb(main):005:0> a.sysread 64*1024 > |IOError: sysread for buffered IO ... > rewind it first to clear buffering. Interesting. It seems to indeed allow for it. I was unable to actually test it on a tape devicesince it appears that eof? calls a read of size 8192: read(3, 0x6c9ba90, 8192) = -1 ENOMEM (Cannot allocate memory) which would be smaller than what I would need [which is ok I can live without eof]. Also as a note, it ends up that, with tape drives the trick is to read from a device into a buffer that's at least as large as the largest "block" of data written onto the tape, or else you'll get ENOMEM. ex: write 1000 bytes File.open('tape_device like /dev/nst2', 'w') do |f| f.syswrite 'a*1000; end now read File.open('tape_device', 'r') do |f| f.sysread 100; end # fails File.open('tape_device', 'r') do |f| f.sysread 1000; end # succeeds Nothing to do with ruby itself, but thought I'd mention it for followers. -r -- Posted via http://www.ruby-forum.com/.