summaryrefslogtreecommitdiff
path: root/bin/clean_sems.sh
blob: 57fbf3e9c0699fcbdcd3446c416a76e4b03abdf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

if [ -z "$USER" ]; then
  USER=`id | sed 's/).*//; s/.*(//'`
fi

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