[erlang-questions] file:read_file/2 bug?

Per Hedeland <>
Fri May 2 12:35:47 CEST 2008

"Christian S" <> wrote:
>On Thu, May 1, 2008 at 8:43 PM, Per Hedeland <> wrote:
>> I don't think any of the Erlang file(3)
>>  functionality is quite up to the general task.
>My approach have been like Serge's second attempt, to open then read
>with a sufficiently big read byte-count. That's an Erlang file-module
>approach. Are you saying that there is problems with that too?

If you can read the whole thing in one call to read(2) (i.e. the OS
system call), you should be safe - but in some cases this may not be
reasonable, some /proc entries can deliver *very* long (exact length not
known in advance) lists of items. And even in the case that it is
reasonable, you may want to double-check whether file:read(FD, N) always
turns into a single call to read(2), no matter how big N is (it probably
does, but...).


More information about the erlang-questions mailing list