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

Function read_command_name

src/bvar/variable.cpp:541–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539// ============= export to files ==============
540
541std::string read_command_name() {
542 std::ifstream fin("/proc/self/stat");
543 if (!fin.is_open()) {
544 return std::string();
545 }
546 int pid = 0;
547 std::string command_name;
548 fin >> pid >> command_name;
549 if (!fin.good()) {
550 return std::string();
551 }
552 // Although the man page says the command name is in parenthesis, for
553 // safety we normalize the name.
554 std::string s;
555 if (command_name.size() >= 2UL && command_name[0] == '(' &&
556 butil::back_char(command_name) == ')') {
557 // remove parenthesis.
558 to_underscored_name(&s,
559 butil::StringPiece(command_name.data() + 1,
560 command_name.size() - 2UL));
561 } else {
562 to_underscored_name(&s, command_name);
563 }
564 return s;
565}
566
567class FileDumper : public Dumper {
568public:

Callers 2

RpcDumpContextMethod · 0.85
dumping_threadFunction · 0.85

Calls 5

back_charFunction · 0.85
to_underscored_nameFunction · 0.85
goodMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected