From owner-freebsd-questions@FreeBSD.ORG Thu Jul 3 14:44:41 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D2ED37B401 for ; Thu, 3 Jul 2003 14:44:41 -0700 (PDT) Received: from smtp4.server.rpi.edu (smtp4.server.rpi.edu [128.113.2.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id CACD443FF9 for ; Thu, 3 Jul 2003 14:44:40 -0700 (PDT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp4.server.rpi.edu (8.12.9/8.12.9) with ESMTP id h63LiX63023228; Thu, 3 Jul 2003 17:44:34 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Thu, 3 Jul 2003 17:44:31 -0400 To: Jim Xochellis , freebsd-questions@freebsd.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: unclaimed-spam X-Scanned-By: CanIt (www . canit . ca) Subject: Re: About newsyslog behavior X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jul 2003 21:44:41 -0000 At 12:08 PM +0300 7/2/03, Jim Xochellis wrote: > >I suspected that some processes are confused because >a *new* log file is created and these processes are >making the assumption that their log file will be always >the same and perhaps they open it once and then work with >the FILE pointer. If a program responds to SIGHUP by re-opening all of it's files, then it really should re-open the log file. If the program does not re-open the logfile when it get a SIGHUP, then it is more accurate to say it is ignoring the SIGHUP (as far as that log file is concerned). Ie, there is no way that it is "correct" for the program to behave in the way you describe, if it is trying to do "the right thing" with the log file. >I have confirmed that newsyslog actually creates a new >log file (instead of copying it and then disposing its >contents) by reading the source of the newsyslog.c file Yes, and that doen because it is the safest and most reliable way for it to rotate a logfile without any hitting any race-conditions. >Having the above in mind, isn't it worthwhile to add an >option in newsyslog in order to avoid the creation of a >new log file when it is inconvenient? This does not seem like a good idea to me. It might work okay in the case where you are keeping no backup files, but it is a really bad idea if you want to rotate the information to backup files. >Isn't it feasible to dispose the contents of the old log >file instead of creating a new one? Anything that I am >missing here? (giving the fact that I am not a unix guru, >only a C programmer) If the program does not have some way to REALLY re-open the log file, then the file-pointer might also be pointing to a specific point in the file. Let's say it is at byte 125000 into the file. You empty the file. The next time the program writes to the log file, it will write to byte 125001 (depending on how the program is written). Some programs may work with this strategy, but others will not. I think you should look at the programs you are having trouble with, and see if there is some alternate way to get them to correctly handle the log file that you want to rotate. disclaimer: I am about to go on holiday/vacation for a few days, so all of the above comments were just my initial reaction. I realize this reply is not very helpful, but I'll try to write up something more helpful if no one else comes up with a good solution for you. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu