From patchwork Thu Jan 26 21:36:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 138073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 36649B6F62 for ; Fri, 27 Jan 2012 09:08:08 +1100 (EST) Received: from localhost ([::1]:40934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqXUA-0000nz-4M for incoming@patchwork.ozlabs.org; Thu, 26 Jan 2012 17:08:02 -0500 Received: from eggs.gnu.org ([140.186.70.92]:54888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqXU4-0000ms-ST for qemu-devel@nongnu.org; Thu, 26 Jan 2012 17:07:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqXU3-00007Y-UX for qemu-devel@nongnu.org; Thu, 26 Jan 2012 17:07:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqXU1-00007A-G7; Thu, 26 Jan 2012 17:07:53 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0QM7oV6005666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 26 Jan 2012 17:07:51 -0500 Received: from lacos-laptop.usersys.redhat.com (vpn1-4-99.ams2.redhat.com [10.36.4.99]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0QLZQIB009083; Thu, 26 Jan 2012 16:35:27 -0500 From: Laszlo Ersek To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org Date: Thu, 26 Jan 2012 22:36:41 +0100 Message-Id: <1327613801-5828-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] keep the PID file locked for the lifetime of the process X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The lockf() call in qemu_create_pidfile() aims at ensuring mutual exclusion. We shouldn't close the pidfile on success, because that drops the lock as well [1]: "File locks shall be released on first close by the locking process of any file descriptor for the file." Coverity may complain again about the leaked file descriptor; let's worry about that later. [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/lockf.html Signed-off-by: Laszlo Ersek Reviewed-by: Markus Armbruster --- Please keep me CC'd, I'm not subscribed. Thanks! os-posix.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/os-posix.c b/os-posix.c index 5c437ca..f4940c8 100644 --- a/os-posix.c +++ b/os-posix.c @@ -348,6 +348,5 @@ int qemu_create_pidfile(const char *filename) return -1; } - close(fd); return 0; }