[erlang-questions] file:read_file/2 bug?
Igor Ribeiro Sucupira
Thu May 1 20:24:49 CEST 2008
On Thu, May 1, 2008 at 10:27 AM, Christian S <> wrote:
> On Thu, May 1, 2008 at 4:36 AM, Serge Aleynikov <> wrote:
> Looking at /erts/emulator/drivers/unix/unix_efile.c one can also see
> that efile_openfile calls stat() on the filename before it open() the
> I dont understand why everything is done in efile_openfile that is
> done, but my guess is that if one first open() the file then use
> fstat() on the file descriptor, then the proc filesystem would report
> nonzero file length.
I've run this C code:
int env_fd = open("/proc/self/environ", O_RDONLY);
struct stat env_stat;
And got env_stat.st_size == 0.
> Understanding would make it worthwile to submit a patch for the efile driver.
> The linux kernel generates the proc file's content as a snapshot at
> the instance the file is opened. Before open() it doesnt know how long
> the content will be.
More information about the erlang-questions