|
|
9de337 |
From 463d3a6b9b960410d4a0304209f4e660d7f1faf2 Mon Sep 17 00:00:00 2001
|
|
|
9de337 |
Message-Id: <463d3a6b9b960410d4a0304209f4e660d7f1faf2@dist-git>
|
|
|
9de337 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
9de337 |
Date: Thu, 5 Aug 2021 13:49:45 +0200
|
|
|
9de337 |
Subject: [PATCH] util: introduce virProcessGroupGet
|
|
|
9de337 |
MIME-Version: 1.0
|
|
|
9de337 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9de337 |
Content-Transfer-Encoding: 8bit
|
|
|
9de337 |
|
|
|
9de337 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9de337 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
9de337 |
(cherry picked from commit 4b39c2aa2e840c9f0c51cf5a7a0d93de51ba8439)
|
|
|
9de337 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9de337 |
|
|
|
9de337 |
https://bugzilla.redhat.com/show_bug.cgi?id=1940276
|
|
|
9de337 |
Message-Id: <365bb0eb78d11505a2b0d6be798462e667074404.1628164129.git.jtomko@redhat.com>
|
|
|
9de337 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
9de337 |
---
|
|
|
9de337 |
src/libvirt_private.syms | 1 +
|
|
|
9de337 |
src/util/virprocess.c | 17 +++++++++++++++++
|
|
|
9de337 |
src/util/virprocess.h | 1 +
|
|
|
9de337 |
3 files changed, 19 insertions(+)
|
|
|
9de337 |
|
|
|
9de337 |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
9de337 |
index b5e86019a5..8b892cf255 100644
|
|
|
9de337 |
--- a/src/libvirt_private.syms
|
|
|
9de337 |
+++ b/src/libvirt_private.syms
|
|
|
9de337 |
@@ -3069,6 +3069,7 @@ virProcessGetMaxMemLock;
|
|
|
9de337 |
virProcessGetNamespaces;
|
|
|
9de337 |
virProcessGetPids;
|
|
|
9de337 |
virProcessGetStartTime;
|
|
|
9de337 |
+virProcessGroupGet;
|
|
|
9de337 |
virProcessGroupKill;
|
|
|
9de337 |
virProcessKill;
|
|
|
9de337 |
virProcessKillPainfully;
|
|
|
9de337 |
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
|
|
|
9de337 |
index 5f01dd1f67..1bc840120a 100644
|
|
|
9de337 |
--- a/src/util/virprocess.c
|
|
|
9de337 |
+++ b/src/util/virprocess.c
|
|
|
9de337 |
@@ -378,6 +378,23 @@ int virProcessGroupKill(pid_t pid, int sig G_GNUC_UNUSED)
|
|
|
9de337 |
}
|
|
|
9de337 |
|
|
|
9de337 |
|
|
|
9de337 |
+/* get process group from a pid */
|
|
|
9de337 |
+pid_t virProcessGroupGet(pid_t pid)
|
|
|
9de337 |
+{
|
|
|
9de337 |
+ if (pid <= 1) {
|
|
|
9de337 |
+ errno = ESRCH;
|
|
|
9de337 |
+ return -1;
|
|
|
9de337 |
+ }
|
|
|
9de337 |
+
|
|
|
9de337 |
+#ifdef WIN32
|
|
|
9de337 |
+ errno = ENOSYS;
|
|
|
9de337 |
+ return -1;
|
|
|
9de337 |
+#else
|
|
|
9de337 |
+ return getpgid(pid);
|
|
|
9de337 |
+#endif
|
|
|
9de337 |
+}
|
|
|
9de337 |
+
|
|
|
9de337 |
+
|
|
|
9de337 |
/*
|
|
|
9de337 |
* Try to kill the process and verify it has exited
|
|
|
9de337 |
*
|
|
|
9de337 |
diff --git a/src/util/virprocess.h b/src/util/virprocess.h
|
|
|
9de337 |
index 0359d7fd9f..9d7c0f479a 100644
|
|
|
9de337 |
--- a/src/util/virprocess.h
|
|
|
9de337 |
+++ b/src/util/virprocess.h
|
|
|
9de337 |
@@ -53,6 +53,7 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw)
|
|
|
9de337 |
|
|
|
9de337 |
int virProcessKill(pid_t pid, int sig);
|
|
|
9de337 |
int virProcessGroupKill(pid_t pid, int sig);
|
|
|
9de337 |
+pid_t virProcessGroupGet(pid_t pid);
|
|
|
9de337 |
|
|
|
9de337 |
int virProcessKillPainfully(pid_t pid, bool force);
|
|
|
9de337 |
int virProcessKillPainfullyDelay(pid_t pid,
|
|
|
9de337 |
--
|
|
|
9de337 |
2.32.0
|
|
|
9de337 |
|