[lug] Polling a file under linux

John Hernandez John.Hernandez at noaa.gov
Mon Apr 21 11:03:35 MDT 2003


On Monday 21 April 2003 10:57 am, Rob Judd wrote:
> I have a C/C++ application that has to connect to an IP address every few
> minutes/seconds (exact timing is not yet clear).  The IP address may
> change as the application is running, and the exact address is stored in
> /etc/myapp.config
>
> Since this file may change at any time I have to check it before each
> connection.  It seems to me that my options are
>
> 1. read the contents of the file before every connection
> 2. stat the file before every connection
>
> both of these are rather expensive, especially if connections are made
> several times a second.
>
> Is there a better way to poll a file to see when it changes?  (This is in
> C or C++)

Can you take the approach of polling the file only if the 
connection/authentication stage fails?

-- 

 |  John Hernandez - NOAA Boulder NOC - 303-497-6392
 |  Mailstop R/OM62. 325 Broadway, Boulder, CO 80305
 |  PGP Public Key ID: 586A7E23



More information about the LUG mailing list