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

Christian S chsu79@REDACTED
Thu May 1 21:38:21 CEST 2008


On Thu, May 1, 2008 at 8:43 PM, Per Hedeland <per@REDACTED> wrote:
>  Your guess is wrong:
>  $ ./stdin_size < /proc/self/environ
>  size=0

First, sorry for spreading mis-information. Thanks for doing the
homework I should have done.

Second. Wow.  I used to do c programming. Why do they do this to themself?

>  AFAIK, the snapshotting happens when you read(2) the file, which can
>  have a variety of interesting effects (probably not in this particular
>  case, but in general). Basically, the Linux /proc file system is handy
>  for the "I just want to have a peek at some system stuff" scenario, but
>  if you want to use it programmatically and get dependable results, you
>  need to be *very* careful.

Looking at some implementations of /proc files, it sure seems more
common to generate content as the file is read. I havent even found a
single occurance of something generating the content at open-time. (I
only recall this being an issue when rewinding and re-reading some
proc file once, but this was ages ago)

> 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?



More information about the erlang-questions mailing list