summaryrefslogtreecommitdiff
path: root/ACE/bin/clean_sems.sh
blob: 7e9227d7a825e51d003abadfeabb6099978a6ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# $Id$

SYSTEM=`uname -s`
IPCS="ipcs"
IPCRM="ipcrm -s"

if [ "$SYSTEM" = "Darwin" ]; then
  USER=`id | sed 's/(.*//; s/uid=//'`
  IPCS="ngvipc -s"
  IPCRM="ngvipc -s -R"
elif [ -z "$USER" ]; then
  USER=`id | sed 's/).*//; s/.*(//'`
fi


case "$SYSTEM" in
  "Linux" )
    ipcs -a | grep $USER | awk '{ print ($2) }' | xargs -r ipcrm sem;
    ;;
  * )
    semids=`$IPCS | grep "^s" | grep $USER | awk '{ print ($2) }'`
    for p in $semids
      do $IPCRM $p
    done
    ;;
esac