Skip to content

fix: keep linux listeners whose pid is hidden - #26

Merged
OhadC merged 4 commits into
mainfrom
linux-hidden-pid-listeners
Nov 7, 2026
Merged

OhadC merged 4 commits into
mainfrom
linux-hidden-pid-listeners

Conversation

@OhadC

@OhadC OhadC commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Closes #13

Summary

On Linux, ss run without sudo lists other users' listeners (e.g. docker-proxy) but leaves out their users:(...) part. leeway used to drop these listeners. It now keeps each one with a null pid.

 ListenerScan.linuxListeners
-  row without users:(...)  → dropped
+  row without users:(...)  → { port, pid: null }

 leeway list           pid ?  (counts as an orphan)
 leeway list --json    "pid": null
 leeway kill           one failed row per hidden listener, kills the visible pids, exits 1
 leeway release        orphan line prints pid ?

RangeKill.failed(plan, failures) now decides the exit code: true when a kill failed or a pid is hidden. RangeKill.render and RangeKill.failed sit side by side, so the "hidden pid = failure" rule is in one module.

Evidence

  • Before: ss row LISTEN 0 128 127.0.0.1:631 0.0.0.0:* → no listener. kill printed nothing is listening.
    After: unit tests, red before the change, green after:
    ListenerScan.listeners("linux", ss)       ⊇ { port: 631, pid: null }
    RangeListing.render(hidden in range)       "  docs  21002  pid ?"
    RangeListing.render(hidden orphan)         "  25000  pid ?"
    RangeKill.render(hidden + visible)         "  pid 70 … killed" / "  pid ?  web 21000  failed: pid hidden, run with sudo to kill it"
    RangeKill.failed(hidden only, no failures) true
    
    pnpm verify passes on Windows: 261 passed, 3 skipped. pnpm test:linux was not run locally because podman isn't installed; CI's ubuntu job covers Linux.

Merge Danger

Door: two-way

The hint says "sudo", not the issue's "root": "root" is a GLOSSARY Avoid term (it means a folder there).

Blast Radius: small

A script reading leeway list --json may now see "pid": null on Linux. leeway kill on Linux now exits 1 where it used to exit 0 and silently skip listeners it couldn't see. Windows and macOS output is unchanged.

OhadC added 4 commits November 7, 2026 17:49
ss without root lists other users' sockets without users:(...). list now
shows them as pid ? (null in --json) and counts them as orphans; kill
reports each as failed with a sudo hint, kills the visible ones, exits 1.

Closes #13
…eners

# Conflicts:
#	packages/leeway/src/cli.ts
@OhadC
OhadC merged commit 37e1393 into main Nov 7, 2026
12 checks passed
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.

Linux: list and kill drop listeners whose pid is hidden

1 participant