lintel 0.2.0
Loading...
Searching...
No Matches
SignalService.h
Go to the documentation of this file.
1#ifndef LINTEL_SIGNALSERVICE_H
2#define LINTEL_SIGNALSERVICE_H
3
4#include <csignal>
5#include <cstdint>
6
8
9#if defined(_WIN32)
10#include <windows.h>// OpenProcess / TerminateProcess (NOMINMAX set by Platform.h)
11#endif// _WIN32
12
13namespace lintel {
16{
17public:
21 {
22#if defined(_WIN32)
23 std::raise(signal);
24#else
26#endif
27 }
28
33 {
34#if defined(_WIN32)
35 static_cast<void>(signal);
36 const HANDLE process = OpenProcess(PROCESS_TERMINATE, FALSE, static_cast<DWORD>(pid));
37 if (process == nullptr) { return; }
38 static_cast<void>(TerminateProcess(process, 1));
39 static_cast<void>(CloseHandle(process));
40#else
41 ::kill(static_cast<::pid_t>(pid), signal);
42#endif
43 }
44};
45
46}// namespace lintel
47#endif// LINTEL_SIGNALSERVICE_H
Definition SignalService.h:16
static void raiseSignal(int32_t signal)
Definition SignalService.h:20
static void kill(lintel::ProcessId pid, int32_t signal)
Definition SignalService.h:32
Definition BaseFeature.h:6
std::int64_t ProcessId
Definition Platform.h:33
constexpr std::string_view type_name()
Definition TypeName.h:9