thoughtbot / thoughtbot/dotfiles
Make whats-in-port and clear-port agree on what is in a port
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 8.2k
- Forks
- 1.8k
- Avg merge
- 10d 14h
- Merged PRs (30d)
- 1
Description
bin/clear-port and bin/whats-in-port are a pair. Since #789 they no longer
agree on what "in the port" means.
$ grep lsof bin/clear-port
lsof -ti4TCP:"$1" -sTCP:LISTEN | xargs -r kill
$ grep lsof bin/whats-in-port
lsof -ni4TCP:"$1"
clear-port now looks only at the listening process. whats-in-port still
lists every socket on that port, so it includes established connections. A
browser with the page open shows up there.
The result is that whats-in-port 3000 can list processes that clear-port 3000 will not touch. Someone reads the first, runs the second, and the thing
they saw is still running.
#789 was right to narrow clear-port. Killing a browser because it had the
page open was the bug. The question is whether whats-in-port should narrow
to match.
Two ways to settle it:
- Add
-sTCP:LISTENtowhats-in-port, so both answer the same question.
Simple, and the pair stays honest. - Leave it wide on purpose, because seeing every holder of a port is useful
when you are working out what is going on. If we choose this, say so in a
comment in both scripts, so the difference reads as deliberate.
Either is defensible. Having it happen by accident is not.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with bin/clear-port and bin/whats-in-port, comparing their lsof commands and the behavior described for listening versus established connections. Confirm with a maintainer whether both scripts should report only listening processes or intentionally differ; done means the decision is implemented or documented in both scripts and their output is no longer accidentally misleading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100