Format command line for display, truncating if needed.
(cmdline: list[str] | None, max_length: int = 80)
| 22 | |
| 23 | |
| 24 | def format_cmdline(cmdline: list[str] | None, max_length: int = 80) -> str: |
| 25 | """Format command line for display, truncating if needed.""" |
| 26 | if not cmdline: |
| 27 | return "<no cmdline>" |
| 28 | full = " ".join(cmdline) |
| 29 | if len(full) <= max_length: |
| 30 | return full |
| 31 | return full[: max_length - 3] + "..." |
| 32 | |
| 33 | |
| 34 | def get_process_tree(proc: psutil.Process) -> list[psutil.Process]: |