OpenBSD manual page server

Manual Page Search Parameters

SHMGET(2) System Calls Manual SHMGET(2)

shmgetget shared memory area identifier

#include <sys/shm.h>

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

() returns the shared memory identifier associated with the key 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 follows:

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.

[]
A shared memory segment is already associated with key and the caller has no permission to access it.
[]
Both IPC_CREAT and IPC_EXCL are set in shmflg, and a shared memory segment is already associated with key.
[]
A shared memory segment is already associated with key and its size is less than the requested size.
[]
A new shared memory identifier could not be created because the system limit for the number of shared memory identifiers has been reached.
[]
was not set in shmflg and no shared memory segment associated with key was found.
[]
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)

November 15, 2014 OpenBSD-current