]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sem_destroy.3
Many pages: Add '\" t' comment where necessary
[thirdparty/man-pages.git] / man3 / sem_destroy.3
CommitLineData
a1eaacb1 1'\" t
c11b1abf 2.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
2c731798 3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
2c731798 5.\"
4c1c5274 6.TH sem_destroy 3 (date) "Linux man-pages (unreleased)"
2c731798
MK
7.SH NAME
8sem_destroy \- destroy an unnamed semaphore
ae0f7f24
AC
9.SH LIBRARY
10POSIX threads library
8fc3b2cf 11.RI ( libpthread ", " \-lpthread )
2c731798
MK
12.SH SYNOPSIS
13.nf
14.B #include <semaphore.h>
68e4db0a 15.PP
2c731798
MK
16.BI "int sem_destroy(sem_t *" sem );
17.fi
18.SH DESCRIPTION
19.BR sem_destroy ()
20destroys the unnamed semaphore at the address pointed to by
21.IR sem .
847e0d88 22.PP
d9bfdb9c 23Only a semaphore that has been initialized by
2c731798
MK
24.BR sem_init (3)
25should be destroyed using
26.BR sem_destroy ().
847e0d88 27.PP
c13182ef 28Destroying a semaphore that other processes or threads are
2c731798
MK
29currently blocked on (in
30.BR sem_wait (3))
d9bfdb9c 31produces undefined behavior.
847e0d88 32.PP
2c731798 33Using a semaphore that has been destroyed produces undefined results,
d9bfdb9c 34until the semaphore has been reinitialized using
2c731798
MK
35.BR sem_init (3).
36.SH RETURN VALUE
37.BR sem_destroy ()
c13182ef 38returns 0 on success;
2c731798 39on error, \-1 is returned, and
c13182ef 40.I errno
2c731798
MK
41is set to indicate the error.
42.SH ERRORS
43.TP
44.B EINVAL
45.I sem
46is not a valid semaphore.
4ef41a41 47.SH ATTRIBUTES
24454159
PH
48For an explanation of the terms used in this section, see
49.BR attributes (7).
c466875e
MK
50.ad l
51.nh
24454159
PH
52.TS
53allbox;
c466875e 54lbx lb lb
24454159
PH
55l l l.
56Interface Attribute Value
57T{
4ef41a41 58.BR sem_destroy ()
24454159
PH
59T} Thread safety MT-Safe
60.TE
c466875e
MK
61.hy
62.ad
63.sp 1
3113c7f3 64.SH STANDARDS
805eb9cc 65POSIX.1-2001, POSIX.1-2008.
2c731798
MK
66.SH NOTES
67An unnamed semaphore should be destroyed with
68.BR sem_destroy ()
69before the memory in which it is located is deallocated.
70Failure to do this can result in resource leaks on some implementations.
71.\" But not on NPTL, where sem_destroy () is a no-op..
47297adb 72.SH SEE ALSO
2c731798
MK
73.BR sem_init (3),
74.BR sem_post (3),
75.BR sem_wait (3),
76.BR sem_overview (7)