Hacker News new | ask | show | jobs
by xorcist 1145 days ago
kill already supports multiple pids

  kill $(lsof -t -i:TCP:$1 -sTCP:LISTEN)
will do just fine. But you probably want listening ports only, hence -s.

Unless you want it to work with millions of listening processes, which would overflow your environment and require the use of xargs.

In that case you probably want GNU xargs with -n and -p to batch the job and run processes in parallel because that's going to take a while.