shmget() - get shared memory segment
#include <sys/shm.h>
int shmget(key_t key, size_t size, int shmflg)
The shmget(2) function creates a shared memory identifier based upon the argument key. The function creates an identifier, data structure, and shared memory segment if:
The new shared memory segment is at least size bytes large. The permission mode (the low-order nine bits of the member shm_perm.mode) are set to the low-order nine bits of shmflg.
If there is already a shared memory segment associated with key, the function returns the identifier for that shared memory segment if the permissions on that shared memory segment allow the calling process to make use of it. If the permissions do not allow it, the function fails. See the errors [EACCES] and [EEXIST].
The members of the data structure associated with the shared memory identifier (described in <sys/shm.h>) are initialized as:
shm_atime | Zero |
shm_ctime | Current time |
shm_dtime | Zero |
shm_lpid | Zero |
shm_nattch | Zero |
shm_perm.cgid | Effective group ID of calling process |
shm_perm.cuid | Effective user ID of calling process |
shm_perm.gid | Effective group ID of calling process |
shm_perm.uid | Effective user ID of calling process |
Low-order nine bits of shm_perm.mode | Low-order nine bits of shflg |
shm_segsz | Value of size |
The header file <sys/shm.h> includes <sys/ipc.h>.
On success, the shmget(2) function returns a shared memory identifier (a non-negative integer).
On failure, shmget(2) returns -1 and sets errno
The shmget(2) function can fail for the following reasons:
(shmflg&IPC_CREAT)&&(shmflg&IPC_EXCL)
is non-zero.shmat(2)
shmctl(2)
shmdt(2)
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@systemmanager.forsenergy.ru to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.