Name

sem_destroy
- destroy an unnamed semaphore

Library

libpthread.lib

Synopsis

  #include <semaphore.h>
  int sem_destroy (sem_t *sem);

Return values

Upon successful completion, a value of zero shall be returned. Other-wise, a value of -1 shall be returned and errno set to indicate the error.

Detailed description

The sem_destroy function destroys the unnamed semaphore pointed to by sem. After a successful call to sem_destroy, sem is unusable until re-initialized by another call to sem_init.

Examples

sem_t psem;   
if (sem_init(&psem, 0, 1) < 0) {
        perror("sem_init");
        return -1;
}
if (sem_destroy(&psem) == 0)
        return -1;
}


Errors

The sem_destroy function will fail if:
[EINVAL]
  The sem argument points to an invalid semaphore.
[EBUSY]
  There are currently threads blocked on the semaphore that sem points to.

See also

sem_init


Feedback

For additional information or queries on this page send feedback

© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.

Top