From owner-cvs-src@FreeBSD.ORG Wed Apr 12 07:12:49 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 DFBA216A401; Wed, 12 Apr 2006 07:12:49 +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 43A1C43D64; Wed, 12 Apr 2006 07:12:46 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 4311652C2F; Wed, 12 Apr 2006 09:12:45 +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 6E32C52C2E; Wed, 12 Apr 2006 09:12:39 +0200 (CEST) Date: Wed, 12 Apr 2006 09:11:25 +0200 From: Pawel Jakub Dawidek To: John-Mark Gurney Message-ID: <20060412071124.GC7031@garage.freebsd.pl> References: <200604112310.k3BNA2DL029129@repoman.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lMM8JwqTlfDpEaS6" Content-Disposition: inline In-Reply-To: <200604112310.k3BNA2DL029129@repoman.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: 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:12:50 -0000 --lMM8JwqTlfDpEaS6 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 11, 2006 at 11:10:02PM +0000, John-Mark Gurney wrote: +> jmg 2006-04-11 23:10:02 UTC +>=20 +> FreeBSD src repository +>=20 +> Modified files: +> lib/libutil pidfile.c=20 +> Log: +> 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... [...] +> snprintf(pidstr, sizeof(pidstr), "%u", getpid()); +> - if (write(fd, pidstr, strlen(pidstr)) !=3D (ssize_t)strlen(pidstr)) { +> + if (pwrite(fd, pidstr, strlen(pidstr), 0) !=3D (ssize_t)strlen(pidstr)= ) { Multiple pidfile_write()s from the same process? If not, then we must truncate the file before writting the PID. Imagine a situation, where PID 10000 is written first and then we overwrite it with 9999. The result will be 99990. --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --lMM8JwqTlfDpEaS6 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFEPKgcForvXbEpPzQRAoozAKC+il045QxwrdSiLrCOvwW/brV05QCeNIwM /3wRjifNUrOyE0vuwC8c2cY= =7n5Y -----END PGP SIGNATURE----- --lMM8JwqTlfDpEaS6--