From owner-cvs-src@FreeBSD.ORG Wed Apr 12 07:51:52 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 2DE0716A409; Wed, 12 Apr 2006 07:51:52 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (arm132.internetdsl.tpnet.pl [83.17.198.132]) by mx1.FreeBSD.org (Postfix) with ESMTP id 49F5F43D48; Wed, 12 Apr 2006 07:51:51 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 3ED5B52BC8; Wed, 12 Apr 2006 09:51:49 +0200 (CEST) Received: from localhost (dlb23.neoplus.adsl.tpnet.pl [83.24.31.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id A6E2E52BC1; Wed, 12 Apr 2006 09:51:43 +0200 (CEST) Date: Wed, 12 Apr 2006 09:50:28 +0200 From: Pawel Jakub Dawidek To: Colin Percival Message-ID: <20060412075028.GF7031@garage.freebsd.pl> References: <200604112310.k3BNA2DL029129@repoman.freebsd.org> <20060412071124.GC7031@garage.freebsd.pl> <443CACCD.2080208@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XStn23h1fwudRqtG" Content-Disposition: inline In-Reply-To: <443CACCD.2080208@freebsd.org> X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 7.0-CURRENT i386 User-Agent: mutt-ng/devel-r535 (FreeBSD) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_00,RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 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:51:52 -0000 --XStn23h1fwudRqtG Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 12, 2006 at 12:31:25AM -0700, Colin Percival wrote: +> 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 mult= iple calls +> > +> to pidfile_write happen, the pidfile will have nul characters pre= pended +> > +> due to the cached file descriptor offset... +> >=20 +> > Multiple pidfile_write()s from the same process? If not, then we must +> > truncate the file before writting the PID. +>=20 +> We already do -- there's a call to ftruncate(fd, 0) a few lines earlier. Right. Hmm, when I placed this ftruncate(2) there, I must thought that it will reset the file position indicator... +> > Imagine a situation, where PID 10000 is written first and then we +> > overwrite it with 9999. The result will be 99990. +>=20 +> 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. That's not possible, because we lock the file. I was more thinking about situation, like: 1. daemon() 2. pidfile_write() 3. SIGHUP 4. fork()/daemon() 5. pidfile_write() --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --XStn23h1fwudRqtG Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFEPLFEForvXbEpPzQRAmLnAKDcX79o5KTB1iNnj/OhRgdTw1NFSACg4YsX Rz/YvmCfltRPQxemm6eM3Xo= =X4eV -----END PGP SIGNATURE----- --XStn23h1fwudRqtG--