MirBSD manpage: shmget(2)

SHMGET(2)                  BSD Programmer's Manual                   SHMGET(2)


     shmget - get shared memory area identifier


     #include <sys/types.h>
     #include <sys/ipc.h>
     #include <sys/shm.h>

     shmget(key_t key, size_t size, int shmflg);


     shmget() returns the shared memory identifier associated with the key

     A shared memory segment is created if either key is equal to IPC_PRIVATE,
     or key does not have a shared memory segment identifier associated with
     it, and the IPC_CREAT bit is set in shmflg.

     If a new shared memory segment is created, the data structure associated
     with it (the shmid_ds structure, see shmctl(2)) is initialized as fol-

     •   shm_perm.cuid and shm_perm.uid are set to the effective uid of the
         calling process.

     •   shm_perm.gid and shm_perm.cgid are set to the effective gid of the
         calling process.

     •   shm_perm.mode is set to the lower 9 bits of shmflg.

     •   shm_lpid, shm_nattch, shm_atime, and shm_dtime are set to 0.

     •   shm_ctime is set to the current time.

     •   shm_segsz is set to the value of size.


     Upon successful completion a positive shared memory segment identifier is
     returned. Otherwise, -1 is returned and the global variable errno is set
     to indicate the error.


     [EACCES]      A shared memory segment is already associated with key and
                   the caller has no permission to access it.

     [EEXIST]      Both IPC_CREAT and IPC_EXCL are set in shmflg, and a shared
                   memory segment is already associated with key.

     [ENOSPC]      A new shared memory identifier could not be created because
                   the system limit for the number of shared memory identif-
                   iers has been reached.

     [ENOENT]      IPC_CREAT was not set in shmflg and no shared memory seg-
                   ment associated with key was found.

     [ENOMEM]      There is not enough memory left to create a shared memory
                   segment of the requested size.


     ipcrm(1), ipcs(1), mmap(2), shmat(2), shmctl(2), ftok(3)

MirBSD #10-current             August 17, 1995                               1

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.

Kontakt / Impressum & Datenschutzerklärung