]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sem_destroy.3
crypt.3: srcfix: rewrap source lines
[thirdparty/man-pages.git] / man3 / sem_destroy.3
CommitLineData
2c731798 1'\" t
c11b1abf 2.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
2c731798 3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
2c731798
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
2c731798
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
10d76543
MK
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
2c731798
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
2c731798 25.\"
4b8c67d9 26.TH SEM_DESTROY 3 2017-09-15 "Linux" "Linux Programmer's Manual"
2c731798
MK
27.SH NAME
28sem_destroy \- destroy an unnamed semaphore
29.SH SYNOPSIS
30.nf
31.B #include <semaphore.h>
68e4db0a 32.PP
2c731798
MK
33.BI "int sem_destroy(sem_t *" sem );
34.fi
68e4db0a 35.PP
2c5f8c8c 36Link with \fI\-pthread\fP.
2c731798
MK
37.SH DESCRIPTION
38.BR sem_destroy ()
39destroys the unnamed semaphore at the address pointed to by
40.IR sem .
847e0d88 41.PP
d9bfdb9c 42Only a semaphore that has been initialized by
2c731798
MK
43.BR sem_init (3)
44should be destroyed using
45.BR sem_destroy ().
847e0d88 46.PP
c13182ef 47Destroying a semaphore that other processes or threads are
2c731798
MK
48currently blocked on (in
49.BR sem_wait (3))
d9bfdb9c 50produces undefined behavior.
847e0d88 51.PP
2c731798 52Using a semaphore that has been destroyed produces undefined results,
d9bfdb9c 53until the semaphore has been reinitialized using
2c731798
MK
54.BR sem_init (3).
55.SH RETURN VALUE
56.BR sem_destroy ()
c13182ef 57returns 0 on success;
2c731798 58on error, \-1 is returned, and
c13182ef 59.I errno
2c731798
MK
60is set to indicate the error.
61.SH ERRORS
62.TP
63.B EINVAL
64.I sem
65is not a valid semaphore.
4ef41a41 66.SH ATTRIBUTES
24454159
PH
67For an explanation of the terms used in this section, see
68.BR attributes (7).
69.TS
70allbox;
71lb lb lb
72l l l.
73Interface Attribute Value
74T{
4ef41a41 75.BR sem_destroy ()
24454159
PH
76T} Thread safety MT-Safe
77.TE
2c731798 78.SH CONFORMING TO
805eb9cc 79POSIX.1-2001, POSIX.1-2008.
2c731798
MK
80.SH NOTES
81An unnamed semaphore should be destroyed with
82.BR sem_destroy ()
83before the memory in which it is located is deallocated.
84Failure to do this can result in resource leaks on some implementations.
85.\" But not on NPTL, where sem_destroy () is a no-op..
47297adb 86.SH SEE ALSO
2c731798
MK
87.BR sem_init (3),
88.BR sem_post (3),
89.BR sem_wait (3),
90.BR sem_overview (7)