[libvirt PATCH 3/6] util: introduce virProcessGroupGet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 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)
 }
 
 
+/* get process group from a pid */
+pid_t virProcessGroupGet(pid_t pid)
+{
+    if (pid <= 1) {
+        errno = ESRCH;
+        return -1;
+    }
+
+#ifdef WIN32
+    errno = 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)
 
 int virProcessKill(pid_t pid, int sig);
 int virProcessGroupKill(pid_t pid, int sig);
+pid_t virProcessGroupGet(pid_t pid);
 
 int virProcessKillPainfully(pid_t pid, bool force);
 int virProcessKillPainfullyDelay(pid_t pid,
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux