From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KyVZC-0000Av-3t for qemu-devel@nongnu.org; Fri, 07 Nov 2008 12:56:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KyVZA-0000A0-Ne for qemu-devel@nongnu.org; Fri, 07 Nov 2008 12:56:17 -0500 Received: from [199.232.76.173] (port=56929 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KyVZA-00009x-HC for qemu-devel@nongnu.org; Fri, 07 Nov 2008 12:56:16 -0500 Received: from mail.codesourcery.com ([65.74.133.4]:55923) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KyVZA-0000bj-7M for qemu-devel@nongnu.org; Fri, 07 Nov 2008 12:56:16 -0500 From: Paul Brook Subject: Re: [Qemu-devel] bug writing pidfile under unix (and fix) Date: Fri, 7 Nov 2008 18:56:11 +0100 References: <20081107170215.7ca43a08@dgym.ktulu> In-Reply-To: <20081107170215.7ca43a08@dgym.ktulu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200811071756.12371.paul@codesourcery.com> 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 Cc: Jim Bailey 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 ? I also notice that we're not removing the file when we exit. Paul