获取进程名,含路径

std::string program_path() {
  const int path_size = 512;
  char *path = (char *)malloc(path_size);
  if (path != NULL) {
    if (readlink("/proc/self/exe", path, path_size) == -1) {
      free(path);
      path = NULL;
    }
  }
  return std::string(path);
}

  

posted on 2022-08-04 14:33  lialin  阅读(37)  评论(0编辑  收藏  举报

导航