Detect when a file has been recreated using a stat watcher
Graham Leggett
minfrin at sharp.fm
Wed Dec 24 11:40:46 CET 2008
Marc Lehmann wrote:
> I don't know, it depends entirely on how you define "logfile rotation",
> which probably relies on whatever program does the actual rotation.
As in the file gets deleted and/or truncated, and the event driven
application watching the file gets notified by some mechanism that this
has happened.
> We were talking about timestamp resolution, and what to do about it. And this
> is cetrainly being explained in the docs.
Er, no, I think you have misunderstood my question.
I am not talking at all about timestamp resolution, a concept which you
are 100% correct is adequately explained in the docs.
What I am talking about is the detection of when a logfile is
moved/deleted/truncated and a new logfile is started from scratch.
From my event driven app, I need to detect when this has occurred, and
close and reopen the logfile in question. (tail -F, in other words)
> I don't think so - but it all depends on how you define it. Note that the
> only sure way of detecting logfile rotation in the general case is to let the
> program that rotates the log tell you. Eberything else is just heuristics.
Hmmm...
Both inotify and kqueue can (apparently) detect file deletion/renaming
events, although it seems that libev does not (yet) expose these events
via any API as yet.
Regards,
Graham
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3287 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20081224/bdbb2b3d/attachment.bin>
More information about the libev
mailing list