Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Jan 2007 12:04:56 -0700
From:      "Andrew Falanga" <af300wsm@gmail.com>
To:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Need to make sure my understanding of newsyslog is correct for a daemon I'm writing
Message-ID:  <340a29540701051104v28d9f2acx5052485350dde6de@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi everybody,

I'm working on the finishing touches to a server program I've just written
and one of the things it needs to log information to a log file.  I'm going
to log to /var/log/file.log and to manage the growth I'm going to add this
log file to the newsyslog.conf file.  However, I'd like to make sure that
the code I'm writing will work with how newsyslog is going to work.

Basically, I'm installing a signal handler for SIGHUP to do the following:

reset the put pointer to the beginning of the file;
flush any data that may be in the buffer;
close the file;
reopen file;


Does this sound correct?  I'm going on the assumption (and this is what I
want to have clarified) that newsyslog, when it finds that file x meets the
rotate criteria, follows these steps:

1) copy file x contents to x.0
2) truncate file x to zero bytes
3) send SIGHUP to process id

Is this how newsyslog would truncate the file?  Am I missing something?
Should my signal handler function look differently?

Thanks for any help,
Andy



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?340a29540701051104v28d9f2acx5052485350dde6de>