On Fri, Jan 05, 2007 at 12:04:56PM -0700, Andrew Falanga wrote:
> 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?
Correct if you desire to truncate your own log file. Don't move to the
beginning. Just flush any pending data to exactly where you were going
to write them in the first place.
> 1) copy file x contents to x.0
Not copy, rename. Can rename a file out from under a process that the
process will still have the original (renamed) file open.
> 2) truncate file x to zero bytes
No, it creates a new file of zero bytes with the original name.
> 3) send SIGHUP to process id
Yes, and now your process has the renamed x.0 open. SIGHUP is asking you
to finish up, close, and open the new x file. You have 10 seconds before
the optional compression starts.
> Is this how newsyslog would truncate the file? Am I missing something?
> Should my signal handler function look differently?
You could log by the Open-append, Write, Close, method for each entry.
Don't ask newyslog to SIGHUP you at all. Much simpler. Extra open/closes
probably don't cost anything measurable.
Or you could log via syslogd.
David Kelly N4HHE, [EMAIL PROTECTED]
Whom computers would destroy, they must first drive mad.
email@example.com mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"