int
semget(key_t key, int nsems, int semflg)
)
system call returns the semaphore identifier associated with
key.
A new set containing
nsems
semaphores is created if either
key
is equal to
IPC_PRIVATE,
or
key
does not have a semaphore set associated with it and the
IPC_CREAT
bit is set in
semflg.
If both the
IPC_CREAT
bit and the
IPC_EXCL
bit are set in
semflg,
and
key
has a semaphore set associated with it already,
the operation will fail.
If a new set of semaphores is created, the data structure associated with it (the semid_ds structure, see semctl(2)) is initialized as follows:
semflg.
nsems.
)
returns a non-negative semaphore identifier if successful.
Otherwise, -1 is returned and
errno
is set to reflect the error.
EACCES]key.
EEXIST]IPC_CREAT
and
IPC_EXCL
are set in
semflg,
and a semaphore set is already associated with
key.
EINVAL]
A semaphore set associated with
key
exists, but has fewer semaphores than the number specified in
nsems.
ENOSPC]ENOENT]IPC_CREAT
is not set in
semflg
and no semaphore set associated with
key
was found.
AT&T System V UNIX.