|
Packit Service |
c5cf8c |
#! /bin/sh
|
|
Packit Service |
c5cf8c |
# courtesy of Jarek Nieplocha, to clean ipc's
|
|
Packit Service |
c5cf8c |
# Modified by Bill Gropp to apply only to calling user
|
|
Packit Service |
c5cf8c |
ipccmd=ipcrm
|
|
Packit Service |
c5cf8c |
username=`whoami`
|
|
Packit Service |
c5cf8c |
for arg in "$@" ; do
|
|
Packit Service |
c5cf8c |
case $arg in
|
|
Packit Service |
c5cf8c |
-help|-u|-us*|-h)
|
|
Packit Service |
c5cf8c |
echo "cleanipcs [-show] [-echo]"
|
|
Packit Service |
c5cf8c |
exit 1
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-echo)
|
|
Packit Service |
c5cf8c |
set -x
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
-show)
|
|
Packit Service |
c5cf8c |
ipccmd="echo ipcrm"
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
*)
|
|
Packit Service |
c5cf8c |
if [ -n "$arg" ] ; then
|
|
Packit Service |
c5cf8c |
echo "Unrecognized argument $arg"
|
|
Packit Service |
c5cf8c |
exit 1
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
;;
|
|
Packit Service |
c5cf8c |
esac
|
|
Packit Service |
c5cf8c |
done
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# LINUX uses an incompatible form of the ipcrm command! Try to detect this
|
|
Packit Service |
c5cf8c |
# An earlier version looked at the output of ipcrm, but that output
|
|
Packit Service |
c5cf8c |
# keeps changing. The following code from Ralf Wildenhues attempts to
|
|
Packit Service |
c5cf8c |
# use the Linux /proc interface instead.
|
|
Packit Service |
c5cf8c |
#statvalue=`ipcrm 2>&1`
|
|
Packit Service |
c5cf8c |
#if [ $? != 0 ] ; then
|
|
Packit Service |
c5cf8c |
# if [ "$statvalue" = 'usage: ipcrm [shm | msg | sem] id' ] ; then
|
|
Packit Service |
c5cf8c |
# UseLinux=1
|
|
Packit Service |
c5cf8c |
# fi
|
|
Packit Service |
c5cf8c |
#fi
|
|
Packit Service |
c5cf8c |
#if [ $UseLinux = 0 ] ; then
|
|
Packit Service |
c5cf8c |
if [ x`uname -s` = xLinux ] ; then
|
|
Packit Service |
c5cf8c |
# try to use /proc interface if possible
|
|
Packit Service |
c5cf8c |
# and hope it does not change too often
|
|
Packit Service |
c5cf8c |
if [ -r /proc/sysvipc/shm ] ; then
|
|
Packit Service |
c5cf8c |
cat /proc/sysvipc/shm \
|
|
Packit Service |
c5cf8c |
| gawk '{if ($8 == uid) printf("%s %s\n", comm, $2)}' uid=$UID comm="$ipccmd shm " \
|
|
Packit Service |
c5cf8c |
| sh > /dev/null
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
ipcs -m \
|
|
Packit Service |
c5cf8c |
| gawk '{if ($3 == name) printf("%s %s\n", comm, $2)}' name=$username comm="$ipccmd shm " \
|
|
Packit Service |
c5cf8c |
| sh > /dev/null
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
if [ -r /proc/sysvipc/sem ] ; then
|
|
Packit Service |
c5cf8c |
cat /proc/sysvipc/sem \
|
|
Packit Service |
c5cf8c |
| gawk '{if ($5 == uid) printf("%s %s\n", comm, $2)}' uid=$UID comm="$ipccmd sem " \
|
|
Packit Service |
c5cf8c |
| sh > /dev/null
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
ipcs -s \
|
|
Packit Service |
c5cf8c |
| gawk '{if ($3 == name) printf("%s %s\n", comm, $2)}' name=$username comm="$ipccmd sem " \
|
|
Packit Service |
c5cf8c |
| sh > /dev/null
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
$ipccmd `ipcs | awk '{if ((($1 == "m") || ($1 == "s")) && ($5 == "'$username'")) print sprintf("-%s %s",$1,$2) }'`
|
|
Packit Service |
c5cf8c |
fi
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Here is the old LINUX code
|
|
Packit Service |
c5cf8c |
# #
|
|
Packit Service |
c5cf8c |
# # For LINUX, we need this instead:
|
|
Packit Service |
c5cf8c |
# ipcs -m | gawk '{if ($3 == name) printf("%s %s\n", comm, $2)}' name=$username comm="$ipccmd shm " | sh > /dev/null
|
|
Packit Service |
c5cf8c |
# ipcs -s | gawk '{if ($3 == name) printf("%s %s\n", comm, $2)}' name=$username comm="$ipccmd sem " | sh > /dev/null
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# mpirun could call this for systems that use SYSV shared memory features,
|
|
Packit Service |
c5cf8c |
# just to keep them friendly.
|