mirror of
https://git.mirrors.martin98.com/https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-19 16:09:10 +08:00
FIX: [STUDIO-2289] impl processname on linux
Change-Id: I0acb5e002b5c945bb8ca6272ad95d602fde17cfb
This commit is contained in:
parent
0f152c635c
commit
670114c1b3
@ -37,6 +37,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1150,7 +1151,16 @@ std::string get_process_name(int pid)
|
||||
while (auto q = strchr(p + 1, '/')) p = q;
|
||||
return p;
|
||||
#else
|
||||
return {};
|
||||
char pathbuf[512] = {0};
|
||||
char proc_path[32] = "/proc/self/exe";
|
||||
if (pid != 0) { snprintf(proc_path, sizeof(proc_path), "/proc/%d/exe", pid); }
|
||||
if (readlink(proc_path, pathbuf, sizeof(pathbuf)) < 0) {
|
||||
perror(NULL);
|
||||
return {};
|
||||
}
|
||||
char *p = pathbuf;
|
||||
while (auto q = strchr(p + 1, '/')) p = q;
|
||||
return p;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user