| 52 | // -------------------- pslist -------------------- |
| 53 | |
| 54 | ByteBuf format_pslist(const Engine& eng) { |
| 55 | const auto& procs = eng.processes(); |
| 56 | std::string out; |
| 57 | out.reserve(64 * 1024); |
| 58 | out += fmt::format( |
| 59 | "# /sys/processes/pslist.txt — flat `ps -ef`-style listing\n" |
| 60 | "# Walks init_task.tasks (the same source as /proc/<pid>-<comm>/).\n" |
| 61 | "# Only thread-group leaders (pid == tgid) appear here; per-thread\n" |
| 62 | "# enumeration is on the roadmap.\n" |
| 63 | "#\n" |
| 64 | "# Total: {} processes\n" |
| 65 | "#\n" |
| 66 | "# {:>6} {:>6} {:>6} {:>6} {:<16} CMD\n" |
| 67 | "# {:->6} {:->6} {:->6} {:->6} {:-<16} {:->24}\n", |
| 68 | procs.size(), |
| 69 | "PID", "PPID", "TGID", "UID", "COMM", "", "", "", "", "", ""); |
| 70 | for (const auto& p : procs) { |
| 71 | out += fmt::format("{:>8} {:>6} {:>6} {:>6} {:<16} {}\n", |
| 72 | p.pid, p.ppid, p.tgid, p.uid, p.comm, |
| 73 | read_cmdline(eng, p)); |
| 74 | } |
| 75 | return ByteBuf(out.begin(), out.end()); |
| 76 | } |
| 77 | |
| 78 | // -------------------- pstree -------------------- |
| 79 |
no test coverage detected