MCPcopy Create free account
hub / github.com/1jehuang/jcode / iter_proc_stat

Function iter_proc_stat

scripts/bench_memory_cli.py:267–284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

265
266
267def iter_proc_stat() -> dict[int, tuple[int, int]]:
268 out: dict[int, tuple[int, int]] = {}
269 for entry in Path("/proc").iterdir():
270 if not entry.name.isdigit():
271 continue
272 try:
273 stat = (entry / "stat").read_text()
274 except Exception:
275 continue
276 try:
277 close = stat.rfind(")")
278 rest = stat[close + 2 :].split()
279 ppid = int(rest[1])
280 pgid = int(rest[2])
281 out[int(entry.name)] = (ppid, pgid)
282 except Exception:
283 continue
284 return out
285
286
287def collect_descendants(root_pids: list[int]) -> set[int]:

Callers 2

collect_descendantsFunction · 0.85

Calls 2

PathClass · 0.85
splitMethod · 0.45

Tested by

no test coverage detected