Date: Wed, 12 Apr 2006 09:11:25 +0200 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: John-Mark Gurney <jmg@FreeBSD.org> Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libutil pidfile.c Message-ID: <20060412071124.GC7031@garage.freebsd.pl> In-Reply-To: <200604112310.k3BNA2DL029129@repoman.freebsd.org> References: <200604112310.k3BNA2DL029129@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060412071124.GC7031>