From owner-cvs-src@FreeBSD.ORG Wed Apr 12 07:31:28 2006 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3475116A400; Wed, 12 Apr 2006 07:31:28 +0000 (UTC) (envelope-from cperciva@freebsd.org) Received: from pd3mo2so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD09C43D48; Wed, 12 Apr 2006 07:31:27 +0000 (GMT) (envelope-from cperciva@freebsd.org) Received: from pd3mr3so.prod.shaw.ca (pd3mr3so-qfe3.prod.shaw.ca [10.0.141.179]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IXL004SQM8FRI00@l-daemon>; Wed, 12 Apr 2006 01:31:27 -0600 (MDT) Received: from pn2ml6so.prod.shaw.ca ([10.0.121.150]) by pd3mr3so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IXL00HE4M8EX4L0@pd3mr3so.prod.shaw.ca>; Wed, 12 Apr 2006 01:31:27 -0600 (MDT) Received: from [192.168.0.60] ([24.82.18.31]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IXL00K0XM8EZUN0@l-daemon>; Wed, 12 Apr 2006 01:31:26 -0600 (MDT) Date: Wed, 12 Apr 2006 00:31:25 -0700 From: Colin Percival In-reply-to: <20060412071124.GC7031@garage.freebsd.pl> To: Pawel Jakub Dawidek Message-id: <443CACCD.2080208@freebsd.org> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Enigmail-Version: 0.94.0.0 References: <200604112310.k3BNA2DL029129@repoman.freebsd.org> <20060412071124.GC7031@garage.freebsd.pl> User-Agent: Thunderbird 1.5 (X11/20060112) Cc: John-Mark Gurney , cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libutil pidfile.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2006 07:31:28 -0000 Pawel Jakub Dawidek wrote: > On Tue, Apr 11, 2006 at 11:10:02PM +0000, John-Mark Gurney wrote: > +> use pwrite to always write at the begining of the file.. If multiple calls > +> to pidfile_write happen, the pidfile will have nul characters prepended > +> due to the cached file descriptor offset... > > Multiple pidfile_write()s from the same process? If not, then we must > truncate the file before writting the PID. We already do -- there's a call to ftruncate(fd, 0) a few lines earlier. > Imagine a situation, where PID 10000 is written first and then we > overwrite it with 9999. The result will be 99990. The only way this can happen is if two different processes call pidfile_write simultaneously and both ftruncate calls complete before either pwrite call starts; I don't think this is really worth worrying about. Colin Percival