Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!dftsrv!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: how do you watch for an incoming file Summary: use fstat if possible Keywords: file directory unix Message-ID: <21010@mimsy.umd.edu> Date: 29 Nov 89 21:50:10 GMT References: <5506@hplabsb.HP.COM> <1989Nov29.042955.8217@virtech.uucp> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 21 In article <1989Nov29.042955.8217@virtech.uucp> cpcahil@virtech.uucp (Conor P. Cahill) writes: > forever loop ... > stat(dir,to get current dir mtime var) If you open the directory, and use fstat on the resulting descriptor, you will accumulate less system time. Unfortunately, it seems that some Unix systems refuse to let you open a directory these days, so you would need something like fd = open(dir, 0); forever loop ... result = fd >= 0 ? fstat(fd, &st) : stat(dir, &st); if (result < 0) er ror er ror ster ril lize (no points for remembering the source of the `er ror' line :-) ) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris