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