util: Introduce virProcessGroupKill

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2021-08-03 14:23:38 +02:00
parent 5998497d5f
commit fc180c741f
3 changed files with 19 additions and 0 deletions

View File

@ -3070,6 +3070,7 @@ virProcessGetMaxMemLock;
virProcessGetNamespaces; virProcessGetNamespaces;
virProcessGetPids; virProcessGetPids;
virProcessGetStartTime; virProcessGetStartTime;
virProcessGroupKill;
virProcessKill; virProcessKill;
virProcessKillPainfully; virProcessKillPainfully;
virProcessKillPainfullyDelay; virProcessKillPainfullyDelay;

View File

@ -361,6 +361,23 @@ int virProcessKill(pid_t pid, int sig)
} }
/* send signal to a process group */
int virProcessGroupKill(pid_t pid, int sig G_GNUC_UNUSED)
{
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 * Try to kill the process and verify it has exited
* *

View File

@ -52,6 +52,7 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw)
G_GNUC_WARN_UNUSED_RESULT; G_GNUC_WARN_UNUSED_RESULT;
int virProcessKill(pid_t pid, int sig); int virProcessKill(pid_t pid, int sig);
int virProcessGroupKill(pid_t pid, int sig);
int virProcessKillPainfully(pid_t pid, bool force); int virProcessKillPainfully(pid_t pid, bool force);
int virProcessKillPainfullyDelay(pid_t pid, int virProcessKillPainfullyDelay(pid_t pid,