#!/bin/sh

user=`whoami`

if test `uname` = "Linux"; then
  shmids_shm=`ipcs -m | grep $user | awk '{ print $2 }'`
  IPCRM_SHM="ipcrm shm"
  shmids_msq=`ipcs -q | grep $user | awk '{ print $2 }'`
  IPCRM_MSQ="ipcrm msg"
else
  shmids_shm=`ipcs -m | grep $user | awk '{ print $2 }'`
  IPCRM_SHM="ipcrm -m"
  shmids_msq=`ipcs -q | grep $user | awk '{ print $2 }'`
  IPCRM_MSQ="ipcrm -q"
fi

for id in $shmids_shm; do
  echo removing shared memory segment: $id
  $IPCRM_SHM $id
done
for id in $shmids_msq; do
  echo removing shared memory segment: $id
  $IPCRM_MSQ $id
done

