| 217 | |
| 218 | #if defined(OS_LINUX) |
| 219 | static PathString GetProcessName() { |
| 220 | butil::fd_guard fd(open("/proc/self/cmdline", O_RDONLY)); |
| 221 | if (fd < 0) { |
| 222 | return "unknown"; |
| 223 | } |
| 224 | char buf[512]; |
| 225 | const ssize_t len = read(fd, buf, sizeof(buf) - 1); |
| 226 | if (len <= 0) { |
| 227 | return "unknown"; |
| 228 | } |
| 229 | buf[len] = '\0'; |
| 230 | // Not string(buf, len) because we needs to buf to be truncated at first \0. |
| 231 | // Under gdb, the first part of cmdline may include path. |
| 232 | return butil::FilePath(std::string(buf)).BaseName().value(); |
| 233 | } |
| 234 | #endif |
| 235 | |
| 236 | PathString GetDefaultLogFile() { |
no test coverage detected