[tpm] Renaming a file with multiple scripts having opened filehandles on it
Madison Kelly
linux at alteeve.com
Fri Oct 2 17:44:45 PDT 2009
Hi all,
Second question of the evening!
My log method can also archive the log file once it reaches a certain
size. Traditionally, I simply closed the file handle, renamed it to
"log.1" and opened a new file handle to the old file name.
However,
Today while testing this, I noticed that if a second program/thread
had an open file handle on the log file being 'rename'ed, it would
follow the log file to the new name. This makes sense, now that I think
of it (I am guessing it tracks the inode?).
What I want to do though is have some way for other threads recognize
that the file name has changed. That way I would be able to close() the
existing file handle and reconnect to the new file with the old name.
I use IO::Handle... Is there a way to do this?
Thanks again!
Madi
More information about the toronto-pm
mailing list