shmget() returns the shared memory identifier associated with the key
key.
A shared memory segment is created if either
key is equal to
IPC_PRIVATE, or
key does not have a shared memory segment identifier associated with it, and the
IPC_CREAT bit is set in
shmflg. If both the
IPC_CREAT bit and the
IPC_EXCL bit are set in
shmflg, and
key has a shared memory segment identifier associated with it already, the operation will fail.
If a new shared memory segment is created, the data structure associated with it (the
shmid_ds structure, see
shmctl(2)) is initialized as follows:
•
shm_perm.cuid and shm_perm.uid are set to the effective uid of the calling process.
•
shm_perm.gid and shm_perm.cgid are set to the effective gid of the calling process.
•
shm_perm.mode is set to the lower 9 bits of shmflg.
•
shm_lpid, shm_nattch, shm_atime, and shm_dtime are set to 0.
•
shm_ctime is set to the current time.
•
shm_segsz is set to the value of size.