sem_lock(3P4)
NAME
sem_lock − lock a counting semaphore
SYNOPSIS
#include <semaphore.h>
int sem_lock(sem)
sem_t ∗sem;
DESCRIPTION
The sem_lock function locks the counting semaphore referenced by sem. If the semaphore value is currently less than or equal to 0, then the semaphore is already locked and the calling process will block until it is able to lock the semaphore or it is interrupted by a signal. If the semaphore value is greater than zero, the calling process will be able to acquire the lock and proceed.
RETURN VALUE
Upon successful completion, the sem_lock function returns a zero. If any of the following conditions occur, the sem_lock function will return -1 and set errno to the corresponding value:
[EINVAL] The argument sem does not refer to a valid counting semaphore.
[EINTR] The calling process was interrupted by the delivery of a signal.
FILES
/usr/lib/libposix4.a
SEE ALSO
sem_destroy(3P4), sem_unlink(3P4), sem_init(3P4), sem_unlock(3P4), sem_trylock(3P4).
WARNING
The interface to sem_lock is based on IEEE Draft Standard P1003.4/D12. This is an unapproved draft, subject to change. Use of information contained in this unapproved draft is at your own risk. This interface will change to reflect any changes made by future drafts of POSIX 1003.4.
CX/UX Programmer’s Reference Manual