13 #ifndef __STOUT_OS_WINDOWS_KILL_HPP__ 14 #define __STOUT_OS_WINDOWS_KILL_HPP__ 16 #include <glog/logging.h> 30 HANDLE process_handle = ::OpenProcess(PROCESS_TERMINATE, FALSE, pid);
31 if (process_handle ==
nullptr) {
32 LOG(ERROR) <<
"os::kill_process(): Failed call to OpenProcess";
37 SharedHandle safe_process_handle(process_handle, ::CloseHandle);
39 if (::TerminateProcess(safe_process_handle.
get_handle(), 1) == 0) {
40 LOG(ERROR) <<
"os::kill_process(): Failed call to TerminateProcess";
57 if (sig ==
SIGKILL || sig == SIGTERM) {
61 LOG(ERROR) <<
"Failed call to os::kill(): " 62 <<
"Signal value: '" << sig <<
"' is not handled. " 63 <<
"Valid Signal values for Windows os::kill() are " 64 <<
"'SIGTERM' and 'SIGKILL'";
71 #endif // __STOUT_OS_WINDOWS_KILL_HPP__ HANDLE get_handle() const
Definition: windows.hpp:90
Definition: windows.hpp:72
const mode_t SIGKILL
Definition: windows.hpp:335
const int KILL_PASS
Definition: kill.hpp:23
const int KILL_FAIL
Definition: kill.hpp:24
Definition: posix_signalhandler.hpp:23
DWORD pid_t
Definition: windows.hpp:181
constexpr Handle HANDLE
Definition: ingress.hpp:37
int kill_process(pid_t pid)
Definition: kill.hpp:28
int kill(pid_t pid, int sig)
Definition: kill.hpp:21
Definition: attributes.hpp:24