The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

sem_close - close a named semaphore (REALTIME)

 SYNOPSIS



#include <semaphore.h>

int sem_close(sem_t *sem);

 DESCRIPTION

The sem_close() function is used to indicate that the calling process is finished using the named semaphore indicated by sem. The effects of calling sem_close() for an unnamed semaphore (one created by sem_init()) are undefined. The sem_close() function deallocates (that is, make available for reuse by a subsequent sem_open() by this process) any system resources allocated by the system for use by this process for this semaphore. The effect of subsequent use of the semaphore indicated by sem by this process is undefined. If the semaphore has not been removed with a successful call to sem_unlink(), then sem_close() has no effect on the state of the semaphore. If the sem_unlink() function has been successfully invoked for name after the most recent call to sem_open() with O_CREAT for this semaphore, then when all processes that have opened the semaphore close it, the semaphore is no longer be accessible.

 RETURN VALUE

Upon successful completion, a value of zero is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.

 ERRORS

The sem_close() function will fail if:
[EINVAL]
The sem argument is not a valid semaphore descriptor.
[ENOSYS]
The function sem_close() is not supported by this implementation.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

semctl(), semget(), semop(), sem_init(), sem_open(), sem_unlink(), <semaphore.h>.

DERIVATION

Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]