diff --git a/bin/clear-port b/bin/clear-port index bc3f4d064e..993c1e2c91 100755 --- a/bin/clear-port +++ b/bin/clear-port @@ -1,14 +1,13 @@ #!/bin/sh -# Kills the process running on the provided port +# Kills the processes listening on the provided port # # clear-port 3000 if [ -n "$1" ]; then - port_num="$(lsof -ti4TCP:"$1")" - if [ $? -eq 0 ]; then - kill "$port_num" - fi + # A port can be held by more than one process, and a forked server's workers + # die with the parent, so signal every PID in a single kill. + lsof -ti4TCP:"$1" -sTCP:LISTEN | xargs -r kill else echo >&2 Usage: clear-port port-number exit 1