shmget(2) System Calls Manual shmget(2) shmget - System V C (libc, -lc) #include int shmget(key_t key, size_t size, int shmflg); shmget() System V, key. ( shmflg key IPC_PRIVATE) . size, , PAGE_SIZE , key IPC_PRIVATE , key IPC_PRIVATE, , key shmflg IPC_CREAT. shmflg IPC_CREAT IPC_EXCL key , shmget() errno EEXIST ( O_CREAT | O_EXCL open(2)). shmflg : IPC_CREAT . , shmget() , key, , . IPC_EXCL IPC_CREAT , . , . SHM_HUGETLB ( Linux 2.6) << >>. Linux Documentation/admin-guide/mm/hugetlbpage.rst. SHM_HUGE_2MB SHM_HUGE_1GB (since Linux 3.8) SHM_HUGETLB hugetlb (2 1 , ) , hugetlb. , 2 SHM_HUGE_SHIFT. , : #define SHM_HUGE_2MB (21 << SHM_HUGE_SHIFT) #define SHM_HUGE_1GB (30 << SHM_HUGE_SHIFT) mmap(2). SHM_NORESERVE ( Linux 2.6.15) This flag serves the same purpose as the mmap(2) MAP_NORESERVE flag. Do not reserve swap space for this segment. When swap space is reserved, one has the guarantee that it is possible to modify the segment. When swap space is not reserved one might get SIGSEGV upon a write if no physical memory is available. See also the discussion of the file /proc/sys/vm/overcommit_memory in proc_sys_vm(5). 9 shmflg , . mode open(2). . , , shmid_ds (. shmctl(2)) : o shm_perm.cuid shm_perm.uid . o shm_perm.cgid shm_perm.gid . o 9 shm_perm.mode 9 shmflg. o shm_segsz size. o shm_lpid, shm_nattch, shm_atime shm_dtime 0. o shm_ctime . , . . -1, errno . EACCES CAP_IPC_OWNER , IPC. EEXIST shmflg IPC_CREAT IPC_EXCL, key. EINVAL size SHMMIN SHMMAX. EINVAL key , size . ENFILE . ENOENT key IPC_CREAT . ENOMEM . ENOSPC (SHMMNI) (SHMALL). EPERM The SHM_HUGETLB flag was specified, but the caller was not privileged (did not have the CAP_IPC_LOCK capability) and is not a member of the hugetlb_shm_group group; see the description of /proc/sys/vm/hugetlb_shm_group in proc_sys_vm(5). POSIX.1-2024. SHM_HUGETLB SHM_NORESERVE Linux. POSIX.1-2001, SVr4. IPC_PRIVATE -- , key_t. key , 9- shmflg . , shmget(): SHMALL , , . Linux /proc/sys/kernel/shmmni. 3.16, : ULONG_MAX - 2^24 ( 32-, 64- ) -- . , ULONG_MAX, , , . , ULONG_MAX. Linux 2.4 Linux 3.15 : SHMMAX / PAGE_SIZE * (SHMMNI / 16) SHMMAX SHMMNI , ( ) 8 -- , . SHMMAX . Linux /proc/sys/kernel/shmmax. 3.16, : ULONG_MAX - 2^24 ( 32-, 64- ) -- . SHMALL , ( ULONG_MAX). From Linux 2.2 up to Linux 3.15, the default value of this limit was 0x2000000 (32 MiB). , : , i386 , , 2.8 , x86-64 -- 127 . SHMMIN : ( 1 , PAGE_SIZE). SHMMNI . Linux 2.2, 128; Linux 2.4, 4096. Linux /proc/sys/kernel/shmmni. (SHMSEG). , Linux Until Linux 2.3.30, Linux would return EIDRM for a shmget() on a shared memory segment scheduled for deletion. IPC_PRIVATE, , , IPC_NEW . shmop(2). memfd_create(2), shmat(2), shmctl(2), shmdt(2), ftok(3), capabilities(7), shm_overview(7), sysvipc(7) () Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.17 8 2026 . shmget(2)