Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KyY1K-0003w5-1e for qemu-devel@nongnu.org; Fri, 07 Nov 2008 15:33:30 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KyY1J-0003vm-Dr for qemu-devel@nongnu.org; Fri, 07 Nov 2008 15:33:29 -0500 Received: from [199.232.76.173] (port=45700 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KyY1J-0003vg-7w for qemu-devel@nongnu.org; Fri, 07 Nov 2008 15:33:29 -0500 Received: from ey-out-1920.google.com ([74.125.78.146]:62344) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KyY1I-0008CA-Rc for qemu-devel@nongnu.org; Fri, 07 Nov 2008 15:33:29 -0500 Received: by ey-out-1920.google.com with SMTP id 4so625618eyk.4 for ; Fri, 07 Nov 2008 12:33:27 -0800 (PST) Date: Fri, 7 Nov 2008 20:33:23 +0000 From: Jim Bailey Subject: Re: [Qemu-devel] bug writing pidfile under unix (and fix) Message-ID: <20081107203323.7e84ba04@dgym.ktulu> In-Reply-To: <4914A1FA.5000208@codemonkey.ws> References: <20081107170215.7ca43a08@dgym.ktulu> <200811071756.12371.paul@codesourcery.com> <4914A1FA.5000208@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Fri, 07 Nov 2008 14:15:54 -0600 Anthony Liguori wrote: > Paul Brook wrote: > > On Friday 07 November 2008, Jim Bailey wrote: > > > >> Hello, > >> > >> In qemu_create_pidfile (osdep.c:229) the current pid and a newline is > >> written to the pidfile. However, the pidfile isn't truncated, so if it > >> is longer than the length of the pid and the newline character you get > >> trailing junk that can really mess up scripts. > >> > > > > Shouldn't we just open with O_TRUNC ? > > > > Definitely. No no no, definitely not, please see my earlier comment. We don't want to wipe the contents of the file until AFTER checking the advisory lock. Regards, dgym > > > I also notice that we're not removing the file when we exit. > > > > It's not terribly useful to remove the file but it couldn't hurt. An > advisory lock is used to ensure that only one process is running at a > given time. > > Regards, > > Anthony Liguori > > > Paul > > > > > > >