In this thread the OP is suggested to use mmap() instead of shmget() to get shared memory in Linux.
I visited this page and this page to get some d
Both methods are viable. mmap method is a little bit more restrictive then shmget, but easier to use. shmget is the old System V shared memory model and has the widest support. mmap/shm_open is the new POSIX way to do shared memory and is easier to use. If your OS permits the use of POSIX shared memory then I would suggest going with that.
Some hints:
fork then mmap with MAP_ANONYMOUS | MAP_SHARED is by far the easiest way - just one call. MAP_ANONYMOUS is however a Linux extension not specified by POSIX.shm_open (+ ftruncate) + mmap with MAP_SHARED is two/three calls. Requires librt on some OSes./dev/shm/ then shm_open is equivalent to opening a file in /dev/shm/.