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 both the
IPC_CREAT
bit and the
IPC_EXCL
bit are set in
shmflg
,
and
key
has a shared memory segment identifier associated with it already,
the operation will fail.
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:
shmflg
.
size
.
EACCES
]
key
and the caller has no permission to access it.
EEXIST
]
IPC_CREAT
and
IPC_EXCL
are set in
shmflg
,
and a shared memory segment is already associated with
key
.
EINVAL
]
key
,
but the size of the segment associated with it is less
than
size
,
which is non-zero.
A shared memory segment
is
to be created, and
size
is less than the system imposed minimum, or greater than the system
imposed maximum (refer to the
kern.ipc
values in
sysctl(7)).
ENOENT
]
IPC_CREAT
is not set in
shmflg
and no shared memory segment associated with
key
was found.
ENOMEM
]
ENOSPC
]AT&T
System V UNIX
.