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

Function getProcessName

KittyMemoryEx/KittyMemoryEx.cpp:8–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace KittyMemoryEx
7{
8 std::string getProcessName(pid_t pid)
9 {
10 if (pid <= 0)
11 return "";
12
13 char filePath[256] = {0};
14 snprintf(filePath, sizeof(filePath), "/proc/%d/cmdline", pid);
15
16 errno = 0;
17 FILE *fp = fopen(filePath, "r");
18 if (!fp)
19 {
20 KITTY_LOGD("Couldn't open cmdline file %s, error=%s", filePath, strerror(errno));
21 return "";
22 }
23
24 char cmdline[128] = {0};
25 fgets(cmdline, sizeof(cmdline), fp);
26 fclose(fp);
27 return cmdline;
28 }
29
30 std::vector<pid_t> getProcessIDs(const std::string &processName)
31 {

Callers 3

initializeMethod · 0.85
getProcessIDsFunction · 0.85
getProcessIDFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected