Skip to content

feat(proc): add cross-platform process and port inspection tool#28

Open
nooscraft wants to merge 2 commits into
ksdme:mainfrom
nooscraft:feature/proc
Open

feat(proc): add cross-platform process and port inspection tool#28
nooscraft wants to merge 2 commits into
ksdme:mainfrom
nooscraft:feature/proc

Conversation

@nooscraft
Copy link
Copy Markdown
Contributor

@nooscraft nooscraft commented May 10, 2026

Summary

  • Adds ut proc with six subcommands: list, name, pid, port, ports, and kill
  • Port-to-process mapping works natively on Linux (/proc/net/tcp), macOS (lsof), and Windows (netstat) with no extra dependencies beyond sysinfo
  • kill sends SIGTERM by default (graceful) or SIGKILL with --force; on Windows both map to a hard kill
  • list and ports render as proper columnar tables; all commands support --json for machine-readable output
  • Duplicate (port, pid) entries, caused by processes binding both IPv4 and IPv6, are deduplicated

Changes

  • src/tools/proc.rs — new tool
  • src/tool.rs — new Output::Table variant that renders a JSON array as a columnar table in human mode and as JSON with --json
  • Cargo.toml — adds sysinfo v0.39, enables preserve_order on serde_json so table column order is deterministic
  • README.md — documents the new tool

Test plan

  • ut proc list renders a columnar table
  • ut proc list --name node --cmd shows full command line as extra column
  • ut proc list --name node shows no cmd column without the flag
  • ut proc pid $$ returns details for the current shell
  • ut proc ports shows no duplicate rows
  • ut proc port <port> finds the owning process (start ut serve --port 9999 first)
  • ut proc port <unused> returns a clear error
  • ut proc kill --port <port> terminates the process (start ut serve --port 9999 first)
  • ut proc kill --pid <pid> terminates by PID
  • ut --json proc list returns a valid JSON array
  • cargo test proc passes all 8 tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant