()
| 265 | |
| 266 | |
| 267 | def 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 | |
| 287 | def collect_descendants(root_pids: list[int]) -> set[int]: |
no test coverage detected