From 5464e23ff5e822b8a99a3cd234c54ff4632ccb98 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Thu, 2 Nov 2017 09:44:34 -0400 Subject: KWSys 2017-11-02 (54f0901a) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 54f0901ad1a1c545a1360a19b5c521857b5a66ec (master). Upstream Shortlog ----------------- Bryon Bean (1): 8e428c18 Process: Add function to kill process (and children) with pid --- Process.h.in | 8 ++++++++ ProcessUNIX.c | 5 +++++ ProcessWin32.c | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/Process.h.in b/Process.h.in index 237001c..6cb9443 100644 --- a/Process.h.in +++ b/Process.h.in @@ -77,6 +77,7 @@ #define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit) #define kwsysProcess_Interrupt kwsys_ns(Process_Interrupt) #define kwsysProcess_Kill kwsys_ns(Process_Kill) +#define kwsysProcess_KillPID kwsys_ns(Process_KillPID) #define kwsysProcess_ResetStartTime kwsys_ns(Process_ResetStartTime) #endif @@ -457,6 +458,13 @@ kwsysEXPORT void kwsysProcess_Interrupt(kwsysProcess* cp); kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp); /** + * Same as kwsysProcess_Kill using process ID to locate process to + * terminate. + * @see kwsysProcess_Kill(kwsysProcess* cp) + */ +kwsysEXPORT void kwsysProcess_KillPID(unsigned long); + +/** * Reset the start time of the child process to the current time. */ kwsysEXPORT void kwsysProcess_ResetStartTime(kwsysProcess* cp); diff --git a/ProcessUNIX.c b/ProcessUNIX.c index e62ef34..718a1aa 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -2485,6 +2485,11 @@ static pid_t kwsysProcessFork(kwsysProcess* cp, #define KWSYSPE_PS_FORMAT "%d %d %*[^\n]\n" #endif +void kwsysProcess_KillPID(unsigned long process_id) +{ + kwsysProcessKill((pid_t)process_id); +} + static void kwsysProcessKill(pid_t process_id) { #if defined(__linux__) || defined(__CYGWIN__) diff --git a/ProcessWin32.c b/ProcessWin32.c index 945fa28..82fdc74 100644 --- a/ProcessWin32.c +++ b/ProcessWin32.c @@ -1466,6 +1466,11 @@ void kwsysProcess_Kill(kwsysProcess* cp) for them to exit. */ } +void kwsysProcess_KillPID(unsigned long process_id) +{ + kwsysProcessKillTree((DWORD)process_id); +} + /* Function executed for each pipe's thread. Argument is a pointer to the kwsysProcessPipeData instance for this thread. -- cgit v0.12