I have a daemon that opens a file and writes to it throughout operation (typically for many days at a time). In order to support log rotation, I want to be able to identify when the file the handle refers to is in a new location from the original.
Is this possible? fstat() doesn't give me anything useful for this situation.
My current solution is, in the log-writing function, testing the existence of the log file and if it's not there, closing the old handle and opening a new handle. This works, but is a hack and has limitations. In my case, our systems group uses a tool for log rotation that requires them to touch the file after rotating it out, which causes my daemon to continue thinking that its file handle points to the correct place.