[libvirt PATCH 2/6] util: Introduce virProcessGroupKill

[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 d58e983b56..c01c8e267b 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -361,6 +361,23 @@ int virProcessKill(pid_t pid, int sig)
 }
 
 
+/* send signal to a process group */
+int virProcessGroupKill(pid_t pid, int sig)
+{
+    if (pid <= 1) {
+        errno = ESRCH;
+        return -1;
+    }
+
+#ifdef WIN32
+    errno = ENOSYS;
+    return -1;
+#else
+    return killpg(pid, sig);
+#endif
+}
+
+
 /*
  * Try to kill the process and verify it has exited
  *
diff --git a/src/util/virprocess.h b/src/util/virprocess.h
index d16e8b23bb..0359d7fd9f 100644
--- a/src/util/virprocess.h
+++ b/src/util/virprocess.h
@@ -52,6 +52,7 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw)
     G_GNUC_WARN_UNUSED_RESULT;
 
 int virProcessKill(pid_t pid, int sig);
+int virProcessGroupKill(pid_t pid, int sig);
 
 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