]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sem_destroy.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / sem_destroy.3
1 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH SEM_DESTROY 3 2021-03-22 "Linux man-pages (unreleased)"
6 .SH NAME
7 sem_destroy \- destroy an unnamed semaphore
8 .SH LIBRARY
9 POSIX threads library
10 .RI ( libpthread ", " \-lpthread )
11 .SH SYNOPSIS
12 .nf
13 .B #include <semaphore.h>
14 .PP
15 .BI "int sem_destroy(sem_t *" sem );
16 .fi
17 .SH DESCRIPTION
18 .BR sem_destroy ()
19 destroys the unnamed semaphore at the address pointed to by
20 .IR sem .
21 .PP
22 Only a semaphore that has been initialized by
23 .BR sem_init (3)
24 should be destroyed using
25 .BR sem_destroy ().
26 .PP
27 Destroying a semaphore that other processes or threads are
28 currently blocked on (in
29 .BR sem_wait (3))
30 produces undefined behavior.
31 .PP
32 Using a semaphore that has been destroyed produces undefined results,
33 until the semaphore has been reinitialized using
34 .BR sem_init (3).
35 .SH RETURN VALUE
36 .BR sem_destroy ()
37 returns 0 on success;
38 on error, \-1 is returned, and
39 .I errno
40 is set to indicate the error.
41 .SH ERRORS
42 .TP
43 .B EINVAL
44 .I sem
45 is not a valid semaphore.
46 .SH ATTRIBUTES
47 For an explanation of the terms used in this section, see
48 .BR attributes (7).
49 .ad l
50 .nh
51 .TS
52 allbox;
53 lbx lb lb
54 l l l.
55 Interface Attribute Value
56 T{
57 .BR sem_destroy ()
58 T} Thread safety MT-Safe
59 .TE
60 .hy
61 .ad
62 .sp 1
63 .SH STANDARDS
64 POSIX.1-2001, POSIX.1-2008.
65 .SH NOTES
66 An unnamed semaphore should be destroyed with
67 .BR sem_destroy ()
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..
71 .SH SEE ALSO
72 .BR sem_init (3),
73 .BR sem_post (3),
74 .BR sem_wait (3),
75 .BR sem_overview (7)