From nobody Sun Feb 8 18:08:47 2026 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=1628009266; cv=none; d=zohomail.com; s=zohoarc; b=AQV+m/JcqhqSmN8D2mezJH/gJrykK++TeqaKXBnCaHplLTM6NbXR7GZmNxv/0rP/Fa65dFEsCrcCn+2/oGs7lzaJWuTmMFpquqr5kgYAiEkkgG/yk4ag5YxH+metcXzq4caHABs60lFJqkdhzZg2sTdo7DE6V1uKlg/vmVbg9eA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628009266; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LbinHCWhC6/E8LgKF6TUv6vaXy3vRZfRWQSJz6abw84=; b=mSWIAro5ZxzPO4W/YuIsSatb1ugRfA1rR1LWswxwPnWTKp6rg2xZsNuUQ6LzlMbQSqnK+rUA+WtgbAwgtGwvs1CIIHH+9J+U1vipWIhkrOc7z/KW5+EKlDxLC1gxZ9vtLVMQwYlxstJgaFRHwPCIlDJJ7lNifXb08wk677YzXjc= 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 1628009266001602.5488632551871; Tue, 3 Aug 2021 09:47:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-539-2Xb2ahBPPh6IVR9xOXzgOg-1; Tue, 03 Aug 2021 12:47:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62068185303C; Tue, 3 Aug 2021 16:47:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37A7D69323; Tue, 3 Aug 2021 16:47:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F007F50051; Tue, 3 Aug 2021 16:47:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 173FDs0G011130 for ; Tue, 3 Aug 2021 11:13:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F5CD4536; Tue, 3 Aug 2021 15:13:54 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A42619C44 for ; Tue, 3 Aug 2021 15:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628009264; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LbinHCWhC6/E8LgKF6TUv6vaXy3vRZfRWQSJz6abw84=; b=YZls5dwU4sHlkK8DR3gh9BUKkGeRXti3X4Pxn7U+gfQzToMJfS2fzce/dXA14ypXJ9eyCw pjU2ZIZk8KTlrFOwqa7+L/fAoKoHws3NwTHCtq8Qb6SEBTdZjDSDtdt7T6nBd32Y5yuHCH eeEzrBEfrfLhZY+gABviRP0xlLWE6po= X-MC-Unique: 2Xb2ahBPPh6IVR9xOXzgOg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/6] util: introduce virProcessGroupGet Date: Tue, 3 Aug 2021 17:13:42 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1628009267679100001 Signed-off-by: J=C3=A1n Tomko --- src/util/virprocess.c | 17 +++++++++++++++++ src/util/virprocess.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index c01c8e267b..bbfa4dbdf0 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -378,6 +378,23 @@ int virProcessGroupKill(pid_t pid, int sig) } =20 =20 +/* get process group from a pid */ +pid_t virProcessGroupGet(pid_t pid) +{ + if (pid <=3D 1) { + errno =3D ESRCH; + return -1; + } + +#ifdef WIN32 + errno =3D ENOSYS; + return -1; +#else + return getpgid(pid); +#endif +} + + /* * Try to kill the process and verify it has exited * diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 0359d7fd9f..9d7c0f479a 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -53,6 +53,7 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw) =20 int virProcessKill(pid_t pid, int sig); int virProcessGroupKill(pid_t pid, int sig); +pid_t virProcessGroupGet(pid_t pid); =20 int virProcessKillPainfully(pid_t pid, bool force); int virProcessKillPainfullyDelay(pid_t pid, --=20 2.31.1