Sure
Step by step:
Gives a human friendly list of shared memory on your system:
gives this on my box at the moment:
Quote:
user@debian:/xfs/tool/own$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 57573377 user 600 196608 2 dest
0x00000000 57606146 user 600 393216 2 dest
0x00000000 75694083 user 600 393216 2 dest
0x00000000 75726852 user 600 196608 2 dest
|
First we need to remove the first empty lines and the header (Shared Memory Segments, key shmid owner,..)
This gives :
Quote:
0x00000000 57573377 user 600 196608 2 dest
0x00000000 57606146 user 600 393216 2 dest
0x00000000 75694083 user 600 393216 2 dest
0x00000000 75726852 user 600 196608 2 dest
|
Then we know that to remove an ipcs we can use ipcrm but that this program wants to ipcs id as argument. So we have to extract column 2:
Code:
ipcs -m | tail +4 | awk '{print $2}'
This gives :
Quote:
57573377
57606146
75694083
75726852
|
And then we make a loop on these id and we pass it to ipcrm.
ipcrm shm $i for shared memory.
The same for semaphores and messages.