Determining shared memory size

What is the best way to determine the size of an existing shared memory
object created with shm_open. One process open/creates it and then sets the
size of the memory object with an ftruncate call. The other process wants
to open the existing shared memory and acquire the size of the object to
properly map it into the local address space.

Thanx,
Dave G.

Since you can get the size via: “ls -l /dev/shmem”, you can use stat()
or fstat().

Daryl Low

Dave G. wrote:

What is the best way to determine the size of an existing shared memory
object created with shm_open. One process open/creates it and then sets the
size of the memory object with an ftruncate call. The other process wants
to open the existing shared memory and acquire the size of the object to
properly map it into the local address space.

Thanx,
Dave G.