| 73 | } |
| 74 | |
| 75 | std::string ThisProcess::BinaryName() |
| 76 | { |
| 77 | std::string binary_name; |
| 78 | |
| 79 | char path[PATH_MAX] = {0}; |
| 80 | FILE* fp = fopen("/proc/self/cmdline", "r"); |
| 81 | if (fp != NULL) { |
| 82 | if (fgets(path, sizeof(path) - 1, fp)) |
| 83 | binary_name = Path::GetBaseName(path); |
| 84 | fclose(fp); |
| 85 | } |
| 86 | // If fopen failed or the process is defunct, |
| 87 | // read binary name from exe softlink. |
| 88 | if (binary_name.empty()) { |
| 89 | binary_name = Path::GetBaseName(BinaryPath()); |
| 90 | } |
| 91 | return binary_name; |
| 92 | } |
| 93 | |
| 94 | std::string ThisProcess::BinaryDirectory() |
| 95 | { |