0

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+?

Frank Meerkötter
  • 2,778
  • 2
  • 20
  • 26

2 Answers2

1

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
  • 45,290
  • 8
  • 103
  • 119
  • 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 Jan 25 '10 at 08:48
  • btw. to figure out who created the shm segment i need to call "ipcs -mp" – Frank Meerkötter Jan 25 '10 at 08:53
0

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.

coderintherye
  • 901
  • 1
  • 11
  • 20