Index of Section 2 Manual Pages

Interix / SUAsem_trywait.2Interix / SUA

sem_trywait(2)                                           sem_trywait(2)

  sem_trywait()

  NAME

    sem_trywait(), sem_wait() - lock a semaphore

  SYNOPSIS

    #include 

    int sem_trywait(sem_t *sem);
    int sem_wait(sem_t *sem);

  DESCRIPTION

    The sem_wait(2) function locks the semaphore object referenced by the sem
    argument. If the semaphore value is zero, the calling thread is blocked
    until the semaphore is unlocked or sem_wait() is interrupted by a signal.
    When sem_wait() returns, the specified semaphore object is locked.

    The sem_trywait(2) function locks the semaphore referenced by the sem
    argument only if the semaphore is not currently locked (that is, the
    semaphore value is positive). Otherwise, it does not lock the semaphore
    and returns immediately.

  RETURN VALUES

    On success, the function returns 0; otherwise, -1 is returned and errno is
    set to an error code to indicate the error.

  ERRORS

    The sem_trywait() function can fail for the following reason:

    [EAGAIN]
        The semaphore was already locked.

    Both functions can fail for the following reasons:

    [EDEADLK]
        A deadlock condition occurred

    [EINTR]
        The function was interrupted by a signal.

    [EINVAL]
        The sem argument does not refer to a valid semaphore.

  SEE ALSO

    semctl(2)

    semget(2)

    semop(2)

    sem_post(2)

    sem_timedwait(2)

  USAGE NOTES

    All of these functions are thread safe.

    None of these functions are async-signal safe.


Interix / SUAHosted at SUA Community for Interix, SUA and SFUInterix / SUA