Skip to content
API Documentation
BastionGuard™
ProcEventMonitor.hpp
Go to the documentation of this file.
1#pragma once
2#include <atomic>
3#include <cstdint>
4#include <functional>
5#include <memory>
6#include <string>
7
8namespace bsc::netlink {
9
10struct ProcEvent {
11 enum class Type {
13 Fork,
14 Exec,
15 Exit,
16 Uid,
17 Gid,
18 Sid,
19 Comm,
20 Ptrace,
21 CoreDump
22 };
23
25 std::uint32_t pid{0};
26 std::uint32_t tgid{0};
27 std::uint32_t parent_pid{0};
28 std::uint32_t parent_tgid{0};
29 std::uint32_t uid{0};
30 std::uint32_t gid{0};
31 std::int32_t exit_code{0};
32 std::uint32_t exit_signal{0};
33 std::string comm;
34};
35
37 public:
38 using Handler = std::function<void(const ProcEvent&)>;
39
42
43 bool start(Handler handler);
44 void stop();
45 bool running() const noexcept { return running_; }
46 static bool available();
47
48 private:
49 class Impl;
50 std::unique_ptr<Impl> impl_;
51 std::atomic_bool running_{false};
52};
53
54} // namespace bsc::netlink