wwbmmm commented on code in PR #3517:
URL: https://github.com/apache/brpc/pull/3517#discussion_r3944026612
##########
src/bvar/default_variables.cpp:
##########
@@ -617,11 +618,26 @@ static void get_cmdline(std::ostream& os, void*) {
struct ReadVersion {
std::string content;
ReadVersion() {
- std::ostringstream oss;
- if (butil::read_command_output(oss, "uname -ap") != 0) {
+ struct utsname buf;
+ if (uname(&buf) != 0) {
LOG(ERROR) << "Fail to read kernel version";
return;
}
+#if defined(__APPLE__) && (defined(__aarch64__) || defined(__arm64__))
+ const char* processor = "arm";
+#elif defined(__APPLE__) && defined(__x86_64__)
+ const char* processor = "i386";
+#else
+ const char* processor = buf.machine;
+#endif
+ std::ostringstream oss;
+ oss << buf.sysname << ' ' << buf.nodename << ' '
+ << buf.release << ' ' << buf.version << ' '
+ << buf.machine << ' ' << processor;
Review Comment:
The reconstructed output is not byte-equivalent to `uname -ap` as stated in
the PR. On Linux, `uname -ap` appends the operating-system identifier as the
final field, e.g. `... aarch64 GNU/Linux`; this new code stops at `machine
processor` and drops that OS field entirely. Additionally, `uname(1)` omits a
field whose value is the literal string "unknown" (common for `uname -p`),
whereas this code always appends `processor` (here equal to `buf.machine`,
producing a duplicated `machine` value).
If exact parity with the previous output is required (e.g. for
scrapers/keying off the string), either append the proper OS name field
(`GNU/Linux` on Linux; none on macOS) and mirror uname's handling of "unknown",
or update the PR description to not claim the output format is preserved. Since
these fields are informational this may be acceptable, but the claim and the
format should match.
---
🤖 This reply was automatically generated by brpc-oncall
--
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]