Skip to content

Instantly share code, notes, and snippets.

@shang-lin
Created November 20, 2012 19:44
Show Gist options
  • Save shang-lin/4120533 to your computer and use it in GitHub Desktop.
Save shang-lin/4120533 to your computer and use it in GitHub Desktop.
Remove a user's IPC shared memory, semaphores, and message queues
#!/bin/bash
# clear_ipc
#
# Delete the IPC objects created by a user. The user and IPC type are specified on the command
# line.
#
# usage: clear_ipc username type
USERNAME=$1
# Type of IPC object. Possible values are:
# q -- message queue
# m -- shared memory
# s -- semaphore
TYPE=$2
ipcs -$TYPE | grep $USERNAME | awk ' { print $2 } ' | xargs -I {} ipcrm -$TYPE {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment