sem_destroy()¶
Purpose¶
Destroys an unnamed POSIX semaphore initialized by sem_init().
Header¶
Prototype¶
Parameters¶
sem: pointer to a POSIX semaphore.
Return Value¶
- Success: returns
0. - Failure: returns
-1and setserrno.
Minimal Example¶
Common Pitfalls¶
- Only destroy a semaphore when no process or thread may still use it.
- Destroying a process-shared semaphore is usually the responsibility of the creator/owner.
sem_destroy()does not release shared memory.