Kill processes by name or by port, and pick which ones from a list.
$ ka node
? Select processes to kill: [Use arrows to move, space to select, <right> to all, <left> to none]
> [x] 41022 node node server.js
[x] 41057 node node /opt/homebrew/bin/npm run dev
[x] 41063 node node /Users/you/app/node_modules/.bin/vitekillall on macOS only matches the exact process name. Dev tools and apps
that spawn piles of subprocesses (helpers, workers, scripts run through
node or python) don't all share that name, so some survive. And when
killall does match, it kills every one of them with no way to keep one.
ka matches against the full command line, shows you every hit, and lets you
untick the ones you want to keep. It can also find whatever is holding a port,
which saves the usual lsof -i :3000, copy the PID, kill routine.
With Go 1.26 or newer:
go install github.com/willosof/ka@latestOr build from source:
git clone https://github.com/willosof/ka.git
cd ka
go build
mv ka /usr/local/bin/ka [options] process_name
ka [options] -p port
-s SIGNAL Signal to send, by number or name (default 15, SIGTERM)
-9, -2, ... Shorthand for -s 9, -s 2, ...
-y Kill every match without asking
-p PORT Find processes by port instead of name
Options go before the process name.
ka node # pick which node processes to stop
ka -9 chrome # same, but with SIGKILL
ka -y -s HUP nginx # send SIGHUP to every match, no prompt
ka -p 3000 # stop whatever is listening on port 3000- By name: uses
pgrep -f, so the name is matched against the whole command line, not just the executable.ka nodewill also match/usr/bin/python3 manage.py --node-id 4. Look at the list before you confirm. - By port: finds TCP sockets listening on the port and UDP sockets bound to it. Clients that are only connected to that port are left alone.
- No matches: prints a message and exits.
- One match: kills it straight away.
- Several matches: opens the list with everything selected. Space toggles a row, Enter kills the selected ones, Ctrl+C cancels.
- With
-y: kills every match without showing the list.
ka never includes itself in the results.
Developed and tested on macOS. It shells out to pgrep, ps, kill and,
for -p, lsof, all of which ship with macOS.
Issues and pull requests are welcome, especially for Linux and Windows
support. Run go test ./... before sending a change.
MIT