Can someone give an example (reasonably) using the shmat () function with a nonzero second parameter?
The manual says:
#include <sys/shm.h>
void *shmat(int shmid, const void *shmaddr, int shmflg);
The shmat () function attaches the shared memory segment associated with the shmid shared memory identifier to the data segment of the calling process. The segment is attached to the address specified by one of the following criteria:
- If it
shmaddris a NULL pointer, the segment is attached to the first available address selected by the system. - If
shmaddrit is not a NULL pointer and (shmflg and SHM_RND) is non-zero, the segment is bound at the address specified (shmaddr - (shmaddr% SHMLBA)). - If
shmaddrit is not a NULL pointer and (shmflg and SHM_RND) is 0, the segment is bound at the address specified by shmaddr.
shmat, , shmaddr, NULL. malloc() 'ed , , (shmid), .