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:LISTEN to whats-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.
bin/clear-portandbin/whats-in-portare a pair. Since #789 they no longeragree on what "in the port" means.
clear-portnow looks only at the listening process.whats-in-portstilllists 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 3000can list processes thatclear-port 3000will not touch. Someone reads the first, runs the second, and the thingthey saw is still running.
#789 was right to narrow
clear-port. Killing a browser because it had thepage open was the bug. The question is whether
whats-in-portshould narrowto match.
Two ways to settle it:
-sTCP:LISTENtowhats-in-port, so both answer the same question.Simple, and the pair stays honest.
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.