Open System Services System Calls Reference Manual (G06.27+, H06.04+)

shmget(2) OSS System Calls Reference Manual
DESCRIPTION
The shmget() function returns the shared memory identier for the shared memory segment
identied by the key parameter. If the key parameter already has a shared memory identier
associated with it and (shmag & IPC_CREAT) is 0 (zero), that identier is returned.
A new shared memory identier, the associated shared memory table entry, and a new shared
memory segment of at least size bytes are created when either of the following is true:
The value IPC_PRIVATE is used for the key parameter.
The key parameter does not already have a shared memory identier associated with it,
and (shmag & IPC_CREAT) is not 0 (zero).
After creating a new shared memory identier, the shmget() function initializes the shared
memory table entry associated with the identier as follows:
The creators user ID eld (shm_perm.cuid) and owners user ID eld (shm_perm.uid)
are set equal to the effective user ID of the calling process.
The creators group ID eld (shm_perm.cgid) and owners group ID eld
(shm_perm.gid) are set equal to the effective group ID of the calling process.
The least-signicant nine bits of the access mode eld (shm_perm.mode) are set equal
to the least-signicant nine bits of the shmag parameter.
The shared memory segment size eld (shm_segsz) is set to the value of the size parame-
ter.
The following elds are all set to 0 (zero):
shm_lpid, the process ID of the latest process that performed a shmat(),
shmdt(),orshmctl() operation
shm_nattch, the number of processes that currently have this region attached
shm_atime, the time of the last shmat() operation
shm_dtime, the time of the last shmdt() operation
The shm_ctime eld is set equal to the current time. This eld is updated when any of
the following events occur:
The shared memory identier is created.
The permissions for the shared memory segment are changed.
The shared memory identier is removed.
The process ID of the process that created the shared memory identier (the shm_cpid
eld) is set to the process ID of the calling process.
The shared memory identier is used for the following purposes:
It identies a specic entry in the system-maintained shared memory table.
It allows detection of references to a previously removed shared memory identier.
758 Hewlett-Packard Company 527186-004