View Full Version : Semaphore Arrays
LackeyLad
4th November 2004, 04:52 PM
should i delete these semaphores? and if so, then how?
------ Semaphore Arrays --------
key semid owner perms nsems
0x00000b62 0 erich 660 1
0x000014e5 32769 erich 660 1
0x00001b86 65538 erich 660 1
0x00006781 98307 erich 660 1
rogue
5th November 2004, 02:09 AM
I suppose it depends on if they're being used or were abandoned... I'm fairly sure the kernel takes care of any housekeeping needed, but you can always check yourself.
The following C program will return the PID of a semid (from ipcs -s) which you can then check with ps to find the process name. Removal of a semaphore set is done with ipcrm -s.
/*
* Compile with gcc -o semtest semtest.c
* Usage: ./semtest <semid>
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int main(int argc, char *argv[])
{
int n = 0;
if(argc > 1)
{
n = semctl(atoi(argv[1]) ,0 , GETPID);
printf("PID = %d\n", n);
}
return n;
}
I wouldn't be surprised to find there's already an equivalent tool for the code above available, but I don't know of it off hand... if any one does, please let me know.
LackeyLad
5th November 2004, 05:51 AM
solid, i used ipcs -s <semid> to remove them all. Thanks
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.