#include "process.h" #include #include #include "file.h" namespace fs = std::filesystem; bool Reichwein::Process::is_running(pid_t pid) { fs::path pid_file{"/proc/" + std::to_string(pid) + "/stat"}; if (!fs::exists(pid_file)) return false; std::string s{Reichwein::File::getFile(pid_file)}; auto pos0{s.find(' ', 0)}; pos0 = s.find(' ', pos0 + 1); pos0++; auto pos1{s.find(' ', pos0 + 1)}; std::string state{s.substr(pos0, pos1 - pos0)}; return state == "R" || state == "S"; }