implement attach and launch

This commit is contained in:
2025-11-17 08:07:40 -08:00
parent 8e1842d412
commit 22f031c268
12 changed files with 327 additions and 39 deletions

View File

@@ -0,0 +1,55 @@
#ifndef LIBEDBG_INCLUDE_PROCESS_H
#define LIBEDBG_INCLUDE_PROCESS_H
#include <filesystem>
#include <memory>
#include <sys/types.h>
namespace edbg {
enum class process_state {
stopped,
running,
exited,
terminated
};
struct stop_reason {
stop_reason(int wait_status);
process_state reason;
std::uint8_t info;
};
class process {
public:
process() = delete;
process(const process &) = delete;
process &operator=(const process &) = delete;
~process();
static std::unique_ptr<process> launch(std::filesystem::path path);
static std::unique_ptr<process> attach(pid_t pid);
void resume();
stop_reason wait_on_signal();
[[nodiscard]] pid_t pid() const { return pid_; }
[[nodiscard]] process_state state() const { return state_; }
private:
process(pid_t pid, bool terminate_on_end)
: pid_(pid), terminate_on_end_(terminate_on_end) {
}
pid_t pid_ = 0;
bool terminate_on_end_ = true;
process_state state_ = process_state::stopped;
};
}
#endif //LIBEDBG_INCLUDE_PROCESS_H