//获得进程路径
std::string get_exec_path()
{
char szlink[1024], szpath[1024];
sprintf(szlink, "/proc/%d/exe", getpid());
int32_t rslt = readlink(szlink, szpath, sizeof(szpath));
if (rslt < 0) return "";
szpath[rslt] = '\0';
char* path_end;
path_end = strrchr(szpath, '/');
if(path_end == nullptr) return "";
std::string strRes;
strRes.append(szpath, (path_end - szpath));
return strRes;
}
//获得进程的名称
std::string get_exec_name()
{
char szlink[1024], szpath[1024];
sprintf(szlink, "/proc/%d/exe", getpid());
int32_t rslt = readlink(szlink, szpath, sizeof(szpath));
if (rslt < 0) return "";
szpath[rslt] = '\0';
char* path_end;
path_end = strrchr(szpath, '/');
if(path_end == nullptr) return "";
std::string strRes;
strRes.append(path_end+1, strlen(path_end+1));
return strRes;
}