I'm not as good as Andrew or Aaron. But let me give it a shot.
keep time variable when you begin traversing the file
While you inside the directory constantly keep getting
current time and subtract from the old_counter when you
began traversing the directory. use off course the
Set an alarm signal.
#define TIMEOUT 60
if your program get the signal
do the following action:
a) Set A flag to 1
b) reset the Alarm signal.
while you are traversing your directory check for the value
of the flag. if it's one stop traversing and exit
loop. Else keep digging into the directory.
I hope that helps.
Hany E. Morcos (Your UNIX BUDDY)
: I'm searching for a possibility to read a directory with timeout. This is
: urgently necessary in AFS (it's a world wide network filesystem) because
: it takes a too long time to read all directory entries for example from
: /afs/ .
: I'm sure this is possible using an undocumented feature of some Unix
: derivates: Use select on the dd_fd component of the DIR structure.
: Since this is not for a "quick and dirty program" I'm not pleased about
: such a solution.
: Matthias Mueller-Reineke