13 #ifndef __STOUT_OS_WINDOWS_KILL_HPP__
14 #define __STOUT_OS_WINDOWS_KILL_HPP__
16 #include <glog/logging.h>
31 HANDLE process_handle = ::OpenProcess(PROCESS_TERMINATE, FALSE, pid);
32 if (process_handle ==
nullptr) {
33 LOG(ERROR) <<
"os::kill_process(): Failed call to OpenProcess";
38 SharedHandle safe_process_handle(process_handle, ::CloseHandle);
40 if (::TerminateProcess(safe_process_handle.
get_handle(), 1) != 0) {
41 LOG(ERROR) <<
"os::kill_process(): Failed call to TerminateProcess";
58 if (sig ==
SIGKILL || sig == SIGTERM) {
62 LOG(ERROR) <<
"Failed call to os::kill(): "
63 <<
"Signal value: '" << sig <<
"' is not handled. "
64 <<
"Valid Signal values for Windows os::kill() are "
65 <<
"'SIGTERM' and 'SIGKILL'";
73 #endif // __STOUT_OS_WINDOWS_KILL_HPP__
HANDLE get_handle() const
Definition: windows.hpp:96
Definition: windows.hpp:78
const mode_t SIGKILL
Definition: windows.hpp:346
const int KILL_PASS
Definition: kill.hpp:24
const int KILL_FAIL
Definition: kill.hpp:25
DWORD pid_t
Definition: windows.hpp:187
constexpr Handle HANDLE
Definition: ingress.hpp:37
int kill_process(pid_t pid)
Definition: kill.hpp:29
int kill(pid_t pid, int sig)
Definition: kill.hpp:21