sem_trylock(3P4)
NAME
sem_trylock − attempt to lock a counting semaphore
SYNOPSIS
#include <semaphore.h>
int sem_trylock(sem)
sem_t ∗sem;
DESCRIPTION
The sem_trylock routine attempts to lock the counting semaphore referenced by sem. If the value of the semaphore is greater than zero, the lock operation succeeds. If the semaphore is already locked, then sem_trylock will return an error.
RETURN VALUE
Upon successful completion, the sem_trylock function returns a zero. If any of the following conditions occur, the sem_trylock function will return -1 and set errno to the corresponding value:
[EINVAL] The argument sem does not refer to a valid counting semaphore.
[EAGAIN] The semaphore is currently locked.
FILES
/usr/lib/libposix4.a
SEE ALSO
sem_destroy(3P4), sem_unlink(3P4), sem_init(3P4), sem_unlock(3P4), sem_lock(3P4).
WARNING
The interface to sem_trylock 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