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

Function read_cmdline_oneline

src/os/linux/csv_export.cpp:35–50  ·  view source on GitHub ↗

Internal helper to read cmdline as a single-line string (NULs → spaces).

Source from the content-addressed store, hash-verified

33
34// Internal helper to read cmdline as a single-line string (NULs → spaces).
35std::string read_cmdline_oneline(const Engine& eng, const Process& p) {
36 if (p.mm == 0) return fmt::format("[{}]", p.comm);
37 ByteBuf raw;
38 try { raw = gen_cmdline(eng.phys(), eng.isf(), eng.kernel(), p); }
39 catch (...) { return ""; }
40 if (raw.empty()) return "";
41 std::string s;
42 s.reserve(raw.size());
43 for (u8 c : raw) {
44 if (c == 0) s.push_back(' ');
45 else if (c < 0x20 || c == 0x7F) s.push_back('?');
46 else s.push_back((char)c);
47 }
48 while (!s.empty() && s.back() == ' ') s.pop_back();
49 return s;
50}
51
52inline u16 be16(u16 x) { return (u16)((x >> 8) | (x << 8)); }
53

Callers 1

format_pslist_csvFunction · 0.70

Calls 2

gen_cmdlineFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected