Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

semaphore

Status
Not open for further replies.

mmcds

MIS
Joined
Jul 5, 2007
Messages
28
Location
US
I am using SuSE Linux and have reached my array limit for semaphores. I did the ipcs -u to see what I am using and ipcs -l to show my limits. I tried the ipcs -s to see what all arrays are being used and it is showing this

------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 360448 nobody 600 1
0x00000000 3997697 nobody 600 1
0x00000000 4030466 nobody 600 1

My question is how do I know what semid is belonging to what process that is running on my machine that I can safely destroy to get some of my arrays back?
 
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h> 
#include <sys/shm.h>


int main(int argc, char **argv) {
int ans;
struct shmid_ds bb;

                                if (argc != 2) {printf("Please provide a shared memory id for creator pid....\n"); exit(1);}
                                ans = atoi(argv[1]);
                                shmctl(ans,IPC_STAT,&bb);
                                printf("Originating process was: %d\n",bb.shm_cpid);
                                return 0;
}

Not nearly fullproof but gives you an idea. I know of no other tool that even gives you this cross-platform.

Code:
for all in `ipcs | awk '/[0-9]+/ {print $2}'` ; do ./quick_ipc.out $all ; done
Originating process was: 26110
Originating process was: 28376
Originating process was: 28376
Originating process was: 28076
Originating process was: 28376
Originating process was: 28376
Originating process was: 4453
Originating process was: 4453
Originating process was: 4453
 
hey macd68. Is this code part of a shell script or part of a kernel tweak?
 
nevermind on my previous question.. I figured it out with a C program. Not used to compiling C programs. Thanks for the suggestion to my original question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top