Question

I can use ipcs(1) to list out the active shared memory objects on a Solaris 10 box, but it lists them by key. I'm opening the objects via shm_open(3), though, which takes a character string as a name to identify the object. Is there a way to list the shared memory objects by name, or to just get the key<->name mapping? I'm mostly interested in something to run from the command line, although an API for doing this would be OK, too. Thanks!

Was it helpful?

Solution

As far as I remember POSIX shared memory under Solaris appears on the file system either directly under /tmp/ as .SHMDxxx files or under /var/tmp/.SHMD/. This might or might not help you and I don't have a Solaris box handy to validate.

OTHER TIPS

I don't know of a way to list names or get key/name mappings. But I think I know an API that will solve your problem.

I think you can attach the segment from the key by using the System V interface, which is also a Posix API. I believe the way it works is something like:

int attach_shmem(key_t key, void** pp){
    void* p;
    int id;

    id = shmget(key, 0, 0);
    if (id < 0) {
        perror("shmget");
        return ERR_SHMGET;
    }
    p = shmat(id, 0, 0);
    if ((long)p == -1) {
        perror("shmat");
        return ERR_SHMAT;
    }
    *pp = p;
    return 0;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top