DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

shmget(S)


shmget -- get shared memory segment identifier

Syntax

cc . . . -lc

#include  <sys/shm.h>

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

Description

The shmget system call returns the shared memory identifier associated with key.

A shared memory identifier and associated data structure and shared memory segment of at least size bytes are created for key if one of the following is true:

Upon creation, the data structure associated with the new shared memory identifier is initialized as follows:

Return value

Upon successful completion, a non-negative integer, namely a shared memory identifier is returned. Otherwise, a value of -1 is returned, and errno is set to indicate the error.

Diagnostics

The shmget system call fails if one or more of the following is true:

[EACCES]
A shared memory identifier exists for key, but operation permission (see Intro(S)) as specified by the low-order 9 bits of shmflg would not be granted.

[EEXIST]
A shared memory identifier exists for key but (shmflg & IPC_CREAT) and (shmflg & IPC_EXCL) are ``true''.

[EINVAL]
size is less than the system-imposed minimum or greater than the system-imposed maximum.

[EINVAL]
A shared memory identifier exists for key, but the size of the segment associated with it is less than size, and size is not equal to zero.

[ENOENT]
A shared memory identifier does not exist for key, and (shmflg & IPC_CREAT) is ``false''.

[ENOMEM]
A shared memory identifier and associated shared memory segment are to be created, but the amount of available memory is not sufficient to fill the request.

[ENOSPC]
A shared memory identifier is to be created, but the system-imposed limit on the maximum number of allowed shared memory identifiers system wide would be exceeded.

[ENOSYS]
The functionality is not supported on this implementation.

Notes

The user must explicitly remove shared memory segments after the last reference to them has been removed.

See also

shmctl(S), shmop(S)

Standards conformance

shmget is conformant with:

X/Open Portability Guide, Issue 3, 1989 .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003