MCPcopy Create free account
hub / github.com/apache/brpc / GetProcessName

Function GetProcessName

src/butil/logging.cc:219–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217
218#if defined(OS_LINUX)
219static 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
236PathString GetDefaultLogFile() {

Callers 1

GetDefaultLogFileFunction · 0.70

Calls 3

BaseNameMethod · 0.80
FilePathClass · 0.50
valueMethod · 0.45

Tested by

no test coverage detected