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

Function format_pslist

src/os/linux/process_views.cpp:54–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52// -------------------- pslist --------------------
53
54ByteBuf 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

Callers 1

build_sys_treeFunction · 0.85

Calls 2

read_cmdlineFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected