[lug] Polling a file under linux
rjudd at mlug.missouri.edu
Mon Apr 21 11:05:52 MDT 2003
On Mon, 21 Apr 2003, John Hernandez wrote:
> 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?
Unfortunately not since the previous address may still accept connections,
but be the wrong place.
More information about the LUG