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.
| 22 | // task_files.h, but keeping it local avoids cross-file coupling for a |
| 23 | // 12-line helper. |
| 24 | std::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 | |
| 41 | std::string fmt_addr(const SocketInfo& s, const std::array<u8,16>& a) { |
| 42 | if (s.family == SocketInfo::AF_INET6) |
no test coverage detected