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

Igor Ribeiro Sucupira igorrs@REDACTED
Thu May 1 06:20:19 CEST 2008


On Wed, Apr 30, 2008 at 11:36 PM, Serge Aleynikov <saleyn@REDACTED> wrote:
> For some reason file:read_file/1 always returns empty binary when
>  reading from any file in the "/proc" filesystem.
>
>  1> file:read_file("/proc/self/environ").
>  {ok,<<>>}


I suppose it must be fetching S bytes from the file, with S being the
file size.  :-)

This behaviour probably has something to do with the fact that
read_file should be an efficient operation.

Igor.

>  2> {ok, FD} = file:open("/proc/self/environ", [read]).
>  {ok,<0.39.0>}
>  3> file:read(FD, 1024).
>  {ok,[82,
>       69,
>       77,
>       ...
>       121|...]}
>
>  Serge



More information about the erlang-questions mailing list