This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Readdir() bug?

On Mon, Feb 25, 2002 at 12:49:39AM +0000, John William wrote:
>From: "John William" <>
>Subject: Readdir() bug?
>Date: Mon, 25 Feb 2002 00:49:39 
>I have a program that behaves differently on Linux and Cygwin.  I'm
>using version 1.3.9 of the DLL.
>The program tries to list all files in a directory by doing opendir(),
>then readdir() until all the entries have been read and then
>closedir().  That works fine, but the time between the opendir() and
>the closedir() can be considerable.
>On Linux, if any files are added to the directory after the opendir(),
>they will not be enumerated by readdir().  On Cygwin, they are (they
>can appear in
>the middle of the file list or at the end - presumably wherever the new
>happened to end up in the directory's file order).
>I am assuming that the Linux behavour is correct.  Cygwin causes the
>program in question to break because it can modify files and copy them
>back into the
>original directory (with a copy followed by a rename to replace the
>file) so readdir() never hits the end of the file list because it keeps
>seeing the newly added files.
>Any help or comments would be appreciated.  Thanks.

>From the Single UNIX (R) Specification, Version 2:

If a file is removed from or added to the directory after the most
recent call to opendir() or rewinddir(), whether a subsequent call to
readdir() returns an entry for that file is unspecified.


Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]