MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / getProcessIDs

Function getProcessIDs

KittyMemoryEx/KittyMemoryEx.cpp:30–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 std::vector<pid_t> getProcessIDs(const std::string &processName)
31 {
32 std::vector<pid_t> pids;
33
34 if (processName.empty())
35 return pids;
36
37 errno = 0;
38 DIR *dir = opendir("/proc/");
39 if (!dir)
40 {
41 KITTY_LOGD("Couldn't open /proc/, error=%s", strerror(errno));
42 return pids;
43 }
44
45 dirent *entry = nullptr;
46 while ((entry = readdir(dir)) != nullptr)
47 {
48 int entry_pid = atoi(entry->d_name);
49 if (entry_pid > 0)
50 {
51 if (processName == getProcessName(entry_pid))
52 {
53 pids.push_back(entry_pid);
54 }
55 }
56 }
57 closedir(dir);
58 return pids;
59 }
60
61 pid_t getProcessID(const std::string &processName)
62 {

Callers

nothing calls this directly

Calls 1

getProcessNameFunction · 0.85

Tested by

no test coverage detected