1 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .TH SEM_DESTROY 3 2021-03-22 "Linux man-pages (unreleased)"
7 sem_destroy \- destroy an unnamed semaphore
10 .RI ( libpthread ", " \-lpthread )
13 .B #include <semaphore.h>
15 .BI "int sem_destroy(sem_t *" sem );
19 destroys the unnamed semaphore at the address pointed to by
22 Only a semaphore that has been initialized by
24 should be destroyed using
27 Destroying a semaphore that other processes or threads are
28 currently blocked on (in
30 produces undefined behavior.
32 Using a semaphore that has been destroyed produces undefined results,
33 until the semaphore has been reinitialized using
38 on error, \-1 is returned, and
40 is set to indicate the error.
45 is not a valid semaphore.
47 For an explanation of the terms used in this section, see
55 Interface Attribute Value
58 T} Thread safety MT-Safe
64 POSIX.1-2001, POSIX.1-2008.
66 An unnamed semaphore should be destroyed with
68 before the memory in which it is located is deallocated.
69 Failure to do this can result in resource leaks on some implementations.
70 .\" But not on NPTL, where sem_destroy () is a no-op..