MCPcopy Create free account
hub / github.com/MemNixFS/MemNixFS / read_cmdline_oneline

Function read_cmdline_oneline

src/os/linux/json_export.cpp:24–39  ·  view source on GitHub ↗

Same cmdline-as-string reader as csv_export.cpp. Could be hoisted to task_files.h, but keeping it local avoids cross-file coupling for a 12-line helper.

Source from the content-addressed store, hash-verified

22// task_files.h, but keeping it local avoids cross-file coupling for a
23// 12-line helper.
24std::string read_cmdline_oneline(const Engine& eng, const Process& p) {
25 if (p.mm == 0) return fmt::format("[{}]", p.comm);
26 ByteBuf raw;
27 try { raw = gen_cmdline(eng.phys(), eng.isf(), eng.kernel(), p); }
28 catch (...) { return ""; }
29 if (raw.empty()) return "";
30 std::string s;
31 s.reserve(raw.size());
32 for (u8 c : raw) {
33 if (c == 0) s.push_back(' ');
34 else if (c < 0x20 || c == 0x7F) s.push_back('?');
35 else s.push_back((char)c);
36 }
37 while (!s.empty() && s.back() == ' ') s.pop_back();
38 return s;
39}
40
41std::string fmt_addr(const SocketInfo& s, const std::array<u8,16>& a) {
42 if (s.family == SocketInfo::AF_INET6)

Callers 1

format_pslist_jsonFunction · 0.70

Calls 2

gen_cmdlineFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected