int sem_close(sem_t *sem);
The sem_close() function closes the semaphore specified
by the sem argument when the calling process is finished with
When a semaphore is closed, sem_close() frees up any
system resources allocated to be used by that semaphore. These resources are
then available for use by a subsequent invocation of the
Using the specified semaphore again (without reopening it) in the same
process results in the semaphore function failing with errno
set to EINVAL.
The sem_close() function does not affect the state of
the semaphore, unless you have previously removed the semaphore with
the sem_unlink() function.
If you have used sem_unlink() to remove the specified
semaphore (after the most recent sem_open() call with
O_CREAT for that semaphore), sem_close()
causes the semaphore to be closed by all processes that have opened it and
it can no longer be accessed.
Attempting to close an unnamed semaphore (that is, a semaphore created
by the sem_init() function) with this function
can result in heap corruption or freeing resources that were not
You should only use sem_close()
with semaphores created by sem_open() and only use
sem_destroy() with semaphores created with
Specifies the named semaphore to be closed.
When successful, sem_close() returns zero.
Otherwise, it returns -1 and sets errno to one of the following
There are currently processes blocked on the semaphore.
The sem argument is not a valid semaphore descriptor.
Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
- sem_init(), sem_open(), sem_unlink(), semctl(), semget(), semop()
PTC MKS Toolkit 10.3 Documentation Build 39.