SYNOPSIS
#include <sys/shm.h>
int shmget(key_t key, size_t size, int shmflg);
DESCRIPTION
The
Upon creation, the internal attributes associated with the new shared memory identifier are initialized as follows:
- shm_perm.cuid, shm_perm.uid, shm_perm.cgid, and shm_perm.gid are set to the effective user ID and effective group ID, respectively, of the calling process.
- The access permission bits of shm_perm.mode are set to the access permission bits of shmflg. shm_segsz is set to the value of size.
- shm_lpid, shm_nattach, shm_atime, and shm_dtime are set to zero.
- shm_ctime is set to the current time.
You must explicitly remove shared memory segments after the last reference to them has been removed.
The
PARAMETERS
- key
-
Specifies either IPC_PRIVATE or a unique key.
- size
-
Is the size in bytes of the shared memory segment.
- shmflg
-
Specifies both the creation and permission bits (for example, IPC_CREAT | 0666).
RETURN VALUES
If successful,
- EACCES
-
A shared memory identifier exists for key but operation permission as specified by the permission bits of shmflg would not be granted.
- EEXIST
-
A shared memory identifier exists for key, but both (shmflg&IPC_CREAT) and (shmflg&IPC_EXCL) are non-zero.
- EINVAL
-
A shared memory identifier exists for key, but the size of the segment associated with it is less than size and size is not equal to zero.
size is less than the system-imposed minimum or greater than the system-imposed maximum.
- ENOENT
-
A shared memory identifier does not exist for key and (shmflg&IPC_CREAT) is zero.
- ENOMEM
-
A shared memory identifier and associated shared memory segment are to be created, but the amount of available memory is not sufficient to fulfill the request.
- ENOSPC
-
A shared memory identifier is to be created, but the system-imposed limit on the maximum number of allowed shared memory identifiers system wide would be exceeded.
CONFORMANCE
UNIX 98.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
None.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
PTC MKS Toolkit 10.4 Documentation Build 39.