mirror of
https://github.com/srid/nixos-config.git
synced 2026-01-08 17:27:22 +08:00
19 lines
451 B
Nix
19 lines
451 B
Nix
{ writeShellApplication, jc, jq, ... }:
|
|
|
|
writeShellApplication {
|
|
name = "fuckport";
|
|
runtimeInputs = [ jc jq ];
|
|
meta.description = ''
|
|
Kill the process with the port open
|
|
|
|
Used only to kill stale ghc.
|
|
'';
|
|
# FIXME: This doesn't work when lsof returns *multiple* processes.
|
|
text = ''
|
|
lsof -i :"$1"
|
|
THEPID=$(lsof -i :"$1" | jc --lsof 2> /dev/null | jq '.[].pid')
|
|
echo "KILL $THEPID ?"
|
|
read -r
|
|
kill "$THEPID"
|
|
'';
|
|
}
|