Show HN: Killport – CLI tool to kill processes running on a specified port
As a somewhat experienced admin, I can&#x27;t imagine killing a process on a port without first understanding what process is using that port and why it is using that port. If a process is supervised, then I can&#x27;t imagine killing a process when there might be process specific logic encoded into a script to try first.<p><pre><code>  lsof -P | grep LISTEN | grep $PORT
  kill $RELEVANT_PID
</code></pre>
The rust script itself uses kill -9, which probably isn&#x27;t the ideal behavior. SIGTERM and then SIGKILL after a timeout is probably the appropriate behavior for a script, but even more appropriate would be to figure out if it&#x27;s supervised and `service stop` it.<p>The real problem with this script is that it violates the unix philosophy (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Unix_philosophy" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Unix_philosophy</a>). &quot;Do one thing and do it well&quot; is the main problem.<p>This program finds processes to kill AND it kills them AND it kills their children and it does each of those things poorly.<p>For this program to be better than `lsof` and `kill`, it would need to implement command line options for which type of signal to send. By the time that is implemented, a program with the same interface as kill will be implemented, and it would be better for that to be it&#x27;s own program that could be piped too. What&#x27;s left would be a program that finds a process listening to a specific port, and there are already plenty of good programs for that.