Last active
October 12, 2021 21:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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