U
unix_fan
What is the best way to poll a directory for the arrival of files?
The OpenGroup
(http://www.opengroup.org/onlinepubs/007908799/xsh/readdir.html)
says:
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.
This would seem to identify rewinddir() as a reliable
synchronization point - a place where the system re-scans the directory on
the disk.
But rewinddir() doesn't return any error messages!
That would imply that no disk I/O is necessary.
This seems to me to be a specification bug. Is that correct?
A related question - what is the cost of an opendir()? If rewinddir()
really does check in with the disk, then what is the cost difference
between opendir() and rewinddir()?
Maybe I'll just use closedir()/opendir() to be safe (but that seems
unfortunate).
The OpenGroup
(http://www.opengroup.org/onlinepubs/007908799/xsh/readdir.html)
says:
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.
This would seem to identify rewinddir() as a reliable
synchronization point - a place where the system re-scans the directory on
the disk.
But rewinddir() doesn't return any error messages!
That would imply that no disk I/O is necessary.
This seems to me to be a specification bug. Is that correct?
A related question - what is the cost of an opendir()? If rewinddir()
really does check in with the disk, then what is the cost difference
between opendir() and rewinddir()?
Maybe I'll just use closedir()/opendir() to be safe (but that seems
unfortunate).