Asthenia0412 opened a new pull request, #3607:
URL: https://github.com/apache/brpc/pull/3607
## Background
brpc builtin command system silently truncates command names longer than 15
characters, because `bvar::read_command_name()` reads from `/proc/self/stat`
whose `comm` field is kernel-limited to `TASK_COMM_LEN` = 16 bytes (15 chars +
null).
## Problem
Hardcoded kernel-level 15-char limit on process name makes RPC debugging
difficult when users define descriptive command names (e.g. long service names).
## Root Cause
The old implementation parsed `/proc/self/stat`:
```cpp
std::ifstream fin("/proc/self/stat");
fin >> pid >> command_name;
```
Linux kernel's `TASK_COMM_LEN = 16` means the `comm` field is always
truncated to 15 characters.
## Solution
Switch to reading from `/proc/self/cmdline` via the existing
`butil::ReadCommandLine()` helper, which returns the full `argv[0]`. This
helper is already used elsewhere in brpc (`GetProgramName`, `pprof_service`),
so no new dependencies are introduced.
## Verification
- `g++ -std=c++17 -fsyntax-only` passes with no errors.
- Quick runtime test confirmed:
- `/proc/self/stat` comm truncates `myhelloworldprocess_test_long` to
`myhelloworldpro` (15 chars)
- `/proc/self/cmdline` returns full `argv[0]` without truncation
Fixes #1251
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]