diff --git a/Process.h.in b/Process.h.in index 237001c604d2aaa31a2942ae7756b47d7e3a273c..6cb94438e9df02ab28f5c9de02c904bbe6fa14c9 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 @@ -456,6 +457,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. */ diff --git a/ProcessUNIX.c b/ProcessUNIX.c index e62ef34470eef188ddb23be8c8fccb63956e3d27..718a1aaef7c951e1e4000725f33032de849d2f6e 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 945fa28427c2995ce2485ec5217d0e5ae60cbec2..82fdc74786da3aad973e5af8ec9206604284fc73 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.