From nobody Thu Nov 6 01:10:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538296909144455.3307292336041; Sun, 30 Sep 2018 01:41:49 -0700 (PDT) Received: from localhost ([::1]:54364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6XIS-0003WV-3a for importer@patchew.org; Sun, 30 Sep 2018 04:41:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WrJ-0002Ih-93 for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:13:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6WrG-0000MU-3g for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:13:45 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:37099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6WrF-0000Jn-So for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:13:42 -0400 Received: by mail-wm1-x332.google.com with SMTP id 185-v6so248900wmt.2 for ; Sun, 30 Sep 2018 01:13:41 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.13.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tiO1ufhNBOZ8MbQ7kBz2WX7h72pOJZPZdCUBjI+UcJo=; b=aGhkZ3Tjx8UWxZvCzf4a6COS5CfRxcV7pgj8gc75h8tjJGAPgdqiL96jwWfELCsf2u ObinWCL3gXoxKUP7c+FpkWbTAiSfuy5SwLu5D26MCAOcVGGw+9y1ACXHLek0ywLZfBVr OHLiSF/V8yYwc8zCkOZwUoqTUjhek57fRSw4kvNpYP19RDwMknYd/TGZsNX4XNY/8Le7 5px7BJY7ikWuvdssVbFq2lahCvxp4ekGkHZsurnyBQR4ZlKRiqSGart5M6TRUlUnhD3F UzQBmeQRL+JnNGToeE6hxaXIQoU44SD3TQfKFRKv0mdmj6u0qdn6hATXjzhUzqJcavth Cytw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=tiO1ufhNBOZ8MbQ7kBz2WX7h72pOJZPZdCUBjI+UcJo=; b=b8zaxeqLBlfbbbIHMXPud8E5JeLWGsRw08FcVK78ewsmD2iNRh1tZV2SYgOyJ+t5Gq QfOQNY7jTr0lRhW1wpzpkus+TSCcpQmgKaYTLBX1Oc5kUIHF18KPFmu4VidMfHul/4+W gHBajNiVzeSVPHHteSzlAqlaLgVfH04/DrC4Dmgv/NBTONQQTSedEPFsxNwv4U13WdJ4 jkuTmH+Y2Xwv60DEkWR/YFPurUGbCjj5cknqgf43HsJIZ4hOatGOM6mO0Wb+hZYOPR02 KGLbCCDwTakEAkeAlNZEJj0QT1VoeVbCh52W0dCpaLE2swWAVbJw8NgyuymVBfvq0hRE XtrA== X-Gm-Message-State: ABuFfojmND4sNBuwrClxzaVgIsKfRytGyjRjLOXnrv4le/Y1Smj/kdBV 8Z8VOE0/94o0Fh/on9s8FUf3roE/ X-Google-Smtp-Source: ACcGV62zh7R2vdME5M8ZalWRGNM9MOhASwdTO0hnqvVG2gLTilLQj49e2c/8tnG8poGuY3nc6TArwQ== X-Received: by 2002:a1c:280a:: with SMTP id o10-v6mr6210858wmo.33.1538295220583; Sun, 30 Sep 2018 01:13:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:12:21 +0200 Message-Id: <1538295197-23704-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 23/79] Delete PID file on exit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Register an exit notifier to remove the PID file. By the time atexit() is called, qemu_write_pidfile() guarantees QEMU owns the PID file, thus we could safely remove it when exiting. Signed-off-by: Marc-Andr=C3=83=C2=A9 Lureau Message-Id: <20180907121319.8607-4-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Marc-Andr=C3=A9 Lureau --- vl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index fa6db17..f2964d9 100644 --- a/vl.c +++ b/vl.c @@ -2560,6 +2560,16 @@ static void qemu_run_exit_notifiers(void) notifier_list_notify(&exit_notifiers, NULL); } =20 +static const char *pid_file; +static Notifier qemu_unlink_pidfile_notifier; + +static void qemu_unlink_pidfile(Notifier *n, void *data) +{ + if (pid_file) { + unlink(pid_file); + } +} + bool machine_init_done; =20 void qemu_add_machine_init_done_notifier(Notifier *notify) @@ -2884,7 +2894,6 @@ int main(int argc, char **argv, char **envp) const char *vga_model =3D NULL; const char *qtest_chrdev =3D NULL; const char *qtest_log =3D NULL; - const char *pid_file =3D NULL; const char *incoming =3D NULL; bool userconfig =3D true; bool nographic =3D false; @@ -3911,6 +3920,9 @@ int main(int argc, char **argv, char **envp) exit(1); } =20 + qemu_unlink_pidfile_notifier.notify =3D qemu_unlink_pidfile; + qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier); + if (qemu_init_main_loop(&main_loop_err)) { error_report_err(main_loop_err); exit(1); --=20 1.8.3.1