|
|
HP-UX Reference > Ssem_close(2)HP-UX 11i Version 2: December 2007 Update |
|
NAMEsem_close() — close a named POSIX semaphore DESCRIPTIONsem_close() is used to close a named semaphore. A successful call to sem_close() will remove the process's descriptor for the semaphore referenced by the specified sem_t structure sem if the semaphore is marked for removal by a call to sem_unlink() and there are no other descriptors referencing this semaphore. When the process's descriptor for the semaphore referenced by sem is removed, subsequent use of this semaphore by this process will fail. Descriptors for named semaphores are also removed by processes on exit. Calling sem_close() does not affect other processes referencing the same semaphore. To use this function, link in the realtime library by specifying -lrt on the compiler or linker command line. RETURN VALUEIf the semaphore was closed and the descriptors referencing it were removed, sem_close() returns 0 to the caller. If the semaphore could not be closed, the call returns -1 and sets errno to indicate the error. ERRORSsem_close() fails and does not perform the requested operation if the following condition is encountered:
WARNINGSA single sem_close() call will make the semaphore unusable by the process no matter how many times that process has called sem_open() for the same semaphore. Subsequent calls to sem_close() by the same process for the same semaphore will result in undefined behavior. |
|