Copyright (C) 2000-2012 |
GNU Info (ipc.info)shmgetshmget ------ A shared memory segment is allocated by a shmget system call: int shmget(key_t key, int size, int shmflg); * key : an integer usually got from `ftok' or IPC_PRIVATE * size : size of the segment in bytes (SHMMIN <= size <= SHMMAX). * shmflg : IPC_CREAT used to create a new resource IPC_EXCL used with IPC_CREAT to ensure failure if the resource exists. rwxrwxrwx access permissions. * returns : shmid on success. -1 on failure. A descriptor for a shared memory segment is allocated if there isn't one corresponding to the given key. The access permissions specified are then copied into the `shm_perm' struct for the segment along with the user-id etc. The user must use the IPC_CREAT flag or key = IPC_PRIVATE to allocate a new segment. If the segment already exists, the access permissions are verified, and a check is made to see that it is not marked for destruction. `size' is effectively rounded up to a multiple of PAGE_SIZE as shared memory is allocated in pages. Errors: EINVAL : (allocate) Size not in range specified above. (procure) Size greater than size of segment. EEXIST : (allocate) IPC_CREAT | IPC_EXCL specified and resource exists. EIDRM : (procure) The resource is marked destroyed or was removed. ENOSPC : (allocate) All id's are taken (max of SHMMNI id's system-wide). Allocating a segment of the requested size would exceed the system wide limit on total shared memory (SHMALL). ENOENT : (procure) Resource does not exist and IPC_CREAT not specified. EACCES : (procure) Do not have permission for specified access. ENOMEM : (allocate) Could not allocate memory for shmid_ds or pg_table. automatically generated by info2www version 1.2.2.9 |