erlang - Elixir File.read returns empty data when accessing /proc/cpuinfo -
when running thing
file.read "/proc/cpuinfo" >> {:ok, ""}
same equivalent erlang function. there reason pattern?
like @josé mentioned proc fs special since file contents generated on fly. if @ file sizes in /proc you'll see have size 0
.
i believe why read
function fails return anything, file empty!
the workaround force-read number of bytes anyway, in erlang can do:
{ok, fd} = file:open("/proc/cpuinfo", [read]). file:read(fd, 1024).
to read content keep reading fixed number of bytes until eof returned read
.
Comments
Post a Comment