-
Notifications
You must be signed in to change notification settings - Fork 64
en_get_process_object
伏秋洛 edited this page Jun 19, 2023
·
1 revision
Get a Process object to perform various operations.
#include "process.h"
using namespace hak;
pid_t pid = 123456;
auto process = std::make_shared<hak::process>(pid);The above code obtains a hak::process object.
To check if the process is alive, you can use waitpid or the cn_proc.h kernel module, but hak also provides an interface for checking the running status by reading /proc/pid/stat (although it is very time-consuming).
#include "process.h"
using namespace hak;
pid_t pid = 123456;
auto process = std::make_shared<hak::process>(pid);
bool running = process->is_running();Only through learning and communication!