Skip to content

Instantly share code, notes, and snippets.

@tstout
Last active September 22, 2020 15:30
Show Gist options
  • Select an option

  • Save tstout/4c93e58a14ae50625a3528e6a7b41bb2 to your computer and use it in GitHub Desktop.

Select an option

Save tstout/4c93e58a14ae50625a3528e6a7b41bb2 to your computer and use it in GitHub Desktop.
close-socket #bash
#!/bin/bash
IFS=$'\n'
for socket in $(lsof -p 361 | grep IPv | grep -v LISTEN)
do
IFS=' ' read -r pname pid host fd _ <<< $socket
echo "close(${fd%?}) for process $pid"
gdb --batch-silent -p $pid --eval-command="call close(${fd%?})"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment