Go to the previous, next section.

shmget

SYNOPSIS

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

PARAMETERS

key: [in] the shared memory segment identificator.

size: [in] size of the segment.

shmflg: [in] flags (see description).

DESCRIPTION

Gets a shared memory segment identifier. If key is IPC_PRIVATE, a new segment is created. Otherwise, the result depends on the value of shmflg:

IPC_CREAT
creates a new segment for the key if it does not already exist.

IPC_EXCL
if there is already a existing segment associated with key, the call fails.

The value of size is rounded up to a multiple of PAGE_SIZE.

The 9 lower bits of shmflg specify the permission bits of the new segment. They have the same layout and meaning as those for files. However, the execute permissions are meaningless for segments.

When creating a segment the system sets the appropriate parameters in the shmid_ds structure associated with the new segment. When accessing an already existing segment, the system simply check if the segment can be accessed.

RETURN VALUE

On success, the call returns the new shared memory segment identificator. On error -1 is returned and errno is set to one of the following values:

Go to the previous, next section.