From: Yukihiro Matsumoto Date: 2009-01-30T06:05:44+09:00 Subject: Re: Errno::ENOMEM reading a device in Ruby, not in Java thou Hi, In message "Re: Errno::ENOMEM reading a device in Ruby, not in Java thou" on Fri, 30 Jan 2009 05:40:45 +0900, Roger Pack writes: |> I didn't know that. In that case, you have to pre-allocate reading |> buffer (string) and specify it to read method. | |Interesting. |Perhaps somebody with brighter eyes can help me out with this? |[how to?] | |>> b = 'a'*129000 |>> a.read b You have to specify the optional second argument: ---------------------------------------------------------------- IO#read ios.read([length [, buffer]]) => string, buffer, or nil ------------------------------------------------------------------------ Reads at most _length_ bytes from the I/O stream, or to the end of file if _length_ is omitted or is +nil+. _length_ must be a non-negative integer or nil. If the optional _buffer_ argument is present, it must reference a String, which will receive the data. b = " "*65000 a.read(b.size, b) |>> a.read 65000 |Errno::ENOMEM: Cannot allocate memory - /dev/nst2 Hmm, since read with number pre-allocate specified sized buffer, it should work. Perhaps you have to use sysread instead of mere read, since read method retries until exact number of bytes specified read. matz.