From nobody Fri May 10 06:08:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695674158; cv=none; d=zohomail.com; s=zohoarc; b=HyeOl4e5J0I0oFpb3BFMamkuNRczZg+nrVU1MFkyCt+TI7zo2U5u+wZu33AqiYw0HKJaU9JuDLjjmB7HmZEazx8KCeREHTnJvTlEAFet7nK0RD2WAdpJTjyKA888netw4LxuiSOKvuQImmPKDYFcn2/sQbpbVHcvh3mIFMzobpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695674158; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=hBVrLuNPKrWe0EvXDu9J7weHPGldjIpTmu7DXY4/5Ls=; b=VL+W7fiQvsiBPVEq1mWST6u/XZ2IxKw42fXUaOutJ/G3N8m7ZqXaI1XFGILvH7sh4P2+v4oxr5yyUaGKrh0st8PstDDG+npVfigY+wzWjvytpqJXXVfE0n2w63t+hYUm0m8mKfzUCgeSuuHZ29RdWwONL9Kl0NF1CqJVdvhDWtY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1695674158658248.06552096040332; Mon, 25 Sep 2023 13:35:58 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-252-lnd7hfT2Ps-Jwo0fNrt58Q-1; Mon, 25 Sep 2023 16:35:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB0DF85A5BA; Mon, 25 Sep 2023 20:35:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFD1728FE; Mon, 25 Sep 2023 20:35:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 57424194658F; Mon, 25 Sep 2023 20:35:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5569E194658C for ; Mon, 25 Sep 2023 20:35:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E7B2410F1BE9; Mon, 25 Sep 2023 20:35:46 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4D7E1005B90 for ; Mon, 25 Sep 2023 20:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695674157; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hBVrLuNPKrWe0EvXDu9J7weHPGldjIpTmu7DXY4/5Ls=; b=RtZg3NTjwqbi/zINOWCP9bh8VAMDJBJ1efOrULLf71PMAeh8Gm6IIaxyQnUW1rZ0RfaFNk utZlFAcc5pGPAdJTb4azCqPr18ymqyg3LvlT5B4T6BHGMEMu0xqDhFI731i0TB5J1DzrZ0 ypIWK6OWY988LSM7VXEPfeoQFOBlHIA= X-MC-Unique: lnd7hfT2Ps-Jwo0fNrt58Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2] util: fix success return for virProcessKillPainfullyDelay() Date: Mon, 25 Sep 2023 15:27:20 -0500 Message-ID: <20230925203546.2788743-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695674160013100001 virProcessKillPainfullyDelay() currently almost always returns 1 or -1, even though the documentation indicates that it should return 0 if the process was terminated gracefully. But the computation of the return code is faulty and the only case that it currently returns 0 is when it is called with the pid of a process that does not exist. Since no callers ever even distinguish between the 0 and 1 response codes, simply get rid of the distinction and return 0 for both cases. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- Change in v2: - just drop the distinction between 0 and 1 and always return 0. Suggested by J=C3=A1n Tomko src/util/virprocess.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 6ce5ef99a9..b6fb17db83 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -363,9 +363,8 @@ pid_t virProcessGroupGet(pid_t pid) /* * Try to kill the process and verify it has exited * - * Returns 0 if it was killed gracefully, 1 if it - * was killed forcibly, -1 if it is still alive, - * or another error occurred. + * Returns 0 if it was killed, -1 if it is still alive or another error + * occurred. * * Callers can provide an extra delay in seconds to * wait longer than the default. @@ -426,7 +425,7 @@ virProcessKillPainfullyDelay(pid_t pid, bool force, uns= igned int extradelay, boo (long long)pid, signame); return -1; } - return signum =3D=3D SIGTERM ? 0 : 1; + return 0; } =20 g_usleep(200 * 1000); --=20 2.41.0