In addition to bvamos's answer, according to the documentation the use of sem
is deprecated :
NAME ipcrm - remove a message queue, semaphore set or shared memory id SYNOPSIS ipcrm [ -M key | -m id | -Q key | -q id | -S key | -s id ] ... deprecated usage
ipcrm [ shm | msg | sem ] id ...
remove shared memory
us ipcrm -m
to remove a shared memory segment by the id
#!/bin/bash
set IPCS_M = ipcs -m | egrep "0x[0-9a-f]+ [0-9]+" | grep $USERNAME | cut -f2 -d" "
for id in $IPCS_M; do
ipcrm -m $id;
done
or ipcrm -M
to remove a shared memory segment by the key
#!/bin/bash
set IPCS_M = ipcs -m | egrep "0x[0-9a-f]+ [0-9]+" | grep $USERNAME | cut -f1 -d" "
for id in $IPCS_M; do
ipcrm -M $id;
done
remove message queues
us ipcrm -q
to remove a shared memory segment by the id
#!/bin/bash
set IPCS_Q = ipcs -q | egrep "0x[0-9a-f]+ [0-9]+" | grep $USERNAME | cut -f2 -d" "
for id in $IPCS_Q; do
ipcrm -q $id;
done
or ipcrm -Q
to remove a shared memory segment by the key
#!/bin/bash
set IPCS_Q = ipcs -q | egrep "0x[0-9a-f]+ [0-9]+" | grep $USERNAME | cut -f1 -d" "
for id in $IPCS_Q; do
ipcrm -Q $id;
done
remove semaphores
us ipcrm -s
to remove a semaphore segment by the id
#!/bin/bash
set IPCS_S = ipcs -s | egrep "0x[0-9a-f]+ [0-9]+" | grep $USERNAME | cut -f2 -d" "
for id in $IPCS_S; do
ipcrm -s $id;
done
or ipcrm -S
to remove a semaphore segment by the key
#!/bin/bash
set IPCS_S = ipcs -s | egrep "0x[0-9a-f]+ [0-9]+" | grep $USERNAME | cut -f1 -d" "
for id in $IPCS_S; do
ipcrm -S $id;
done