Skip to content

Instantly share code, notes, and snippets.

@tsaavik
Last active October 12, 2021 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsaavik/7590342 to your computer and use it in GitHub Desktop.
Save tsaavik/7590342 to your computer and use it in GitHub Desktop.
Kill all IPC semaphores. Useful when someone forgets to properly clean up. Borrowed and enhanced from a stackoverflow question.
#!/bin/bash
PATH="/bin:/usr/bin"
ipcs
read -p "press enter to kill all the ipc process owned by ${USER}"
IPCS_S=$(ipcs -s | egrep "0x[0-9a-f]+ [0-9]+" | grep ${USER} | cut -f2 -d" ")
IPCS_M=$(ipcs -m | egrep "0x[0-9a-f]+ [0-9]+" | grep ${USER} | cut -f2 -d" ")
IPCS_Q=$(ipcs -q | egrep "0x[0-9a-f]+ [0-9]+" | grep ${USER} | cut -f2 -d" ")
for id in $IPCS_M; do
ipcrm -m $id;
done
for id in $IPCS_S; do
ipcrm -s $id;
done
for id in $IPCS_Q; do
ipcrm -q $id;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment