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