Internal helper to read cmdline as a single-line string (NULs → spaces).
| 33 | |
| 34 | // Internal helper to read cmdline as a single-line string (NULs → spaces). |
| 35 | std::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 | |
| 52 | inline u16 be16(u16 x) { return (u16)((x >> 8) | (x << 8)); } |
| 53 |
no test coverage detected