Is there a way to kill a process listening on a given port (e.g. in
lsof -t -i tcp:8000 | xargs kill) from a shell script that will also work on
cygwin, as well as
The initial part of the problem of killing processes that are listening on a given port is identifying the process.
lsof isn't available on Cygwin, but the
fuser tool is (as part of the
psmisc package) and is documented in its man page as:
fuser - identify processes using files or sockets
There is a demonstration in the EXAMPLES section of the manual that shows
fuser telnet/tcp shows all processes at the (local) TELNET port.
(You may need to run your cygwin shell as an administrator.)