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

Function render_node

src/os/linux/process_views.cpp:82–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80namespace {
81
82void render_node(const std::unordered_map<u32, std::vector<const Process*>>& children,
83 const Process* root, std::string prefix, bool last,
84 std::string& out, int depth)
85{
86 if (depth > 64) return; // sanity guard against ppid cycles
87 // Tree connector for this node.
88 out += prefix;
89 out += last ? "\\-- " : "+-- ";
90 out += fmt::format("{} {}\n", root->pid, root->comm);
91
92 auto it = children.find(root->pid);
93 if (it == children.end()) return;
94 const auto& kids = it->second;
95 for (std::size_t i = 0; i < kids.size(); ++i) {
96 std::string next_prefix = prefix + (last ? " " : "| ");
97 render_node(children, kids[i], std::move(next_prefix),
98 i + 1 == kids.size(), out, depth + 1);
99 }
100}
101
102} // anonymous
103

Callers 1

format_pstreeFunction · 0.85

Calls 2

findMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected