in reply to Re: Monitoring directory for new files
in thread Monitoring directory for new files

If a file isn't finished being created, your read loop will hang while waiting for EOF.

I'm sure this is wrong (since we're talking about plain files, not pipes or sockets), but I can't test it right now.

  • Comment on Re^2: Monitoring directory for new files

Replies are listed 'Best First'.
Re^3: Monitoring directory for new files
by Marshall (Canon) on Jan 20, 2010 at 06:12 UTC
    If that's not true, then what happens? I figure the reading process will keep trying to read until EOF. It will not see EOF until the other process which is writing the file has closed it. I could be mistaken, but again if it doesn't work like this, then what happens in the "reading process"?

    So basically, yes this is like a pipe. I think Ikegami's test is correct.

      You are mistaken. Tested on Win and Linux.

      It stops reading when it reaches the current EOF, saying that it reached EOF. It doesn't matter that some process still has an open file handle to the file.

      If it was a pipe or socket, it would block as you describe.