The segment is attached for reading if (shmflg & SHM_RDONLY) is
"true"; otherwise, it is attached for reading and writing. It is not
possible to attach a segment for write only.
If the shared memory segment has never been attached to by any process
prior to the current shmat() call, shmaddr must be specified as zero
and the segment is attached at a location selected by the operating
system. That location is identical in all processes accessing that
shared memory object. Once the operating system selects a location
for a shared memory segment, the same location will be used across any
subsequent shmat() and shmdt() calls on the segment until it is
removed by the IPC_RMID operation of shmctl().
If this is not the first shmat() call on the shared memory segment
throughout the system, shmaddr must either be zero or contain a
nonzero address that is identical to the one returned from previous
shmat() calls for that segment. Even if no processes are currently
attached to the segment, as long as the segment has been attached
before, the same rule applies.