[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Program is using a deleted file warnings (tiger)



On Mon, Nov 03, 2003 at 12:20:28PM -0800, Ross Boylan wrote:
| Tiger is giving me lots of reports like
| OLD: --WARN-- [kis012w] Program apcupsd (pid 32630, parent 32628) is using a deleted file: 22188
| +/lib/libc-2.3.2.so.dpkg-new
| OLD: --WARN-- [kis012w] Program apcupsd (pid 32630, parent 32628) is using a deleted file: 86 983
| +/var/log/apcupsd.events.1 (deleted)
| 
| Most of the concern libraries with .dpkg-new
| 
| This looks as if it has something to do with how dpkg does upgrades,
| but I'm a little puzzled that the warnings concern dpkg-new files.
| And apcupsd.events.1 doesn't fit that pattern.  I know that logrotate
| moves and renames files as it goes, but why is apcupsd writing to
| anything other than the current log file?

What happens if you restart apcupsd?  As for the log file, the way
UNIX systems handle files is :
    fopen( "/path/to/file" )
        open a file specifying the path; a "file handle" is returned;
        the "handle" is something which the kernel can translate into
        the actual file and is not related to the path, except the
        path is used to find the handle when opening the file
    fputs( file_handle )
        the various methods for writing to a file take a handle as the
        parameter; the methods that write to a file don't care about
        paths

logrotate renames the file, but the application may still have the
file open, and thus is writing not where you want/expect it to.  There
are various solutions to this.  One is for the application not to keep
the file open.  Another is for the application to respond to some
signal (eg HUP or USR1) and then use logrotate's "postrotate" script
feature to signal the app to close and reopen the log file.  Another
is to restart the application in logrotate's postrotate script.  The
final solution, that I am aware of, is to use logrotate's
"copytruncate" method.  copytruncate introduces some issues of its
own, but basically it copies the data from the file into a new file
rather than renaming.  This way the app doesn't need to do anything
with reopening the file, yet the logs are still rotated.

HTH,
-D

-- 
But As for me and my household, we will serve the Lord.
        Joshua 24:15
 
www: http://dman13.dyndns.org/~dman/            jabber: dman@dman13.dyndns.org

Attachment: pgpwuW2Wv1fJJ.pgp
Description: PGP signature


Reply to: