You could reimplement your own version of ipcs
that gives the same output regardless of the OS. This requires some system-level programming though.
On Linux ipcs
uses shmctl(0, SHM_INFO, ...)
to find out the index of the highest used shared memory segment, then runs shmctl(index, SHM_STAT, ...)
in a loop over all indexes from 0
to the highest index in order to obtain information about each segment. This should also work on FreeBSD (not documented but apparent from the kernel source), although on that OS ipcs
uses sysctl
to read the values of kern.ipc.shm*
.
On Solaris ipcs
uses shmids(NULL, 0, &nids)
to obtain the number of segments IDs, then calls shmids(&ids, nids, ...)
to obtain the list of actual IDs and then uses shmctl(id, IPC_STAT, ...)
to obtain information on each segment.
ipcs
is a fairly old instrument and one would not expect its output to change much in the future, at least not until POSIX shared memory completely displaces SysV IPC.