[erlang-questions] file:read_file won't read from /proc

Jachym Holecek <>
Thu Mar 4 17:07:33 CET 2010


# Martin DeMello 2010-03-04:
> 4> {ok, B} = file:read_file("/proc/cpuinfo").
> {ok,<<>>}
> Why is B empty?

The read_file/1 thing check file size and then attempts to read exactly
that many bytes. The size of /proc/cpuinfo is zero[*], thus read_file/1
correctly reads zero bytes and represents the result with empty binary.

Gotta love UN*X for its sense of consistency, right? ;-)

	-- Jachym

[*] Checked on NetBSD and Linux.

More information about the erlang-questions mailing list