views:

206

answers:

2

I would like to find all shared memory segments used by a given process. I am especially interested in figuring out the shmid so i can use it in calls to shmctl().

On Solaris i would just read /proc/$PID/map to figure out that information (field pr_shmid). The contents of that file are defined by struct prmap_t in sys/procfs.

AIX also has a /proc/$PID/map file. There is also a struct prmap but unfortunately it is missing the pr_shmid field.

Any ideas how i can achieve this on AIX5.3+?

A: 

I don't know about AIX in particular, but I think the ipcs command is fairly standard where SysV IPC is supported, so I'd expect the ipcs -m command to give the appropriate information; parsing the output of that might be an option, if you can't find a better way.

Matthew Slattery
Yes, i am afraid i have to settle with that solution. I tried to figure out which syscalls/library calls are used by "ipcs -m" by running it through "truss" but unfortunately "ipcs" is setuid root on AIX...
Frank Meerkötter
btw. to figure out who created the shm segment i need to call "ipcs -mp"
Frank Meerkötter
A: 

svmon -P will list the process memory segments by type.

You can also use -S to see what PIDs are attached to a segment. with -S, first run ipcs -bmS, then take the SID w/o the 0x, and use it with

svmon -lS [SID]

That will return the PIDs attached.

nowarninglabel