OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man3 / sem_destroy.3
1 '\" t
2 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
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.
13 .\"
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
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.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH SEM_DESTROY 3 2014-03-03 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 sem_destroy \- destroy an unnamed semaphore
29 .SH SYNOPSIS
30 .nf
31 .B #include <semaphore.h>
32 .sp
33 .BI "int sem_destroy(sem_t *" sem );
34 .fi
35 .sp
36 Link with \fI\-pthread\fP.
37 .SH DESCRIPTION
38 .BR sem_destroy ()
39 destroys the unnamed semaphore at the address pointed to by
40 .IR sem .
41
42 Only a semaphore that has been initialized by
43 .BR sem_init (3)
44 should be destroyed using
45 .BR sem_destroy ().
46
47 Destroying a semaphore that other processes or threads are
48 currently blocked on (in
49 .BR sem_wait (3))
50 produces undefined behavior.
51
52 Using a semaphore that has been destroyed produces undefined results,
53 until the semaphore has been reinitialized using
54 .BR sem_init (3).
55 .SH RETURN VALUE
56 .BR sem_destroy ()
57 returns 0 on success;
58 on error, \-1 is returned, and
59 .I errno
60 is set to indicate the error.
61 .SH ERRORS
62 .TP
63 .B EINVAL
64 .I sem
65 is not a valid semaphore.
66 .SH ATTRIBUTES
67 .SS Multithreading (see pthreads(7))
68 The
69 .BR sem_destroy ()
70 function is thread-safe.
71 .SH CONFORMING TO
72 POSIX.1-2001.
73 .SH NOTES
74 An unnamed semaphore should be destroyed with
75 .BR sem_destroy ()
76 before the memory in which it is located is deallocated.
77 Failure to do this can result in resource leaks on some implementations.
78 .\" But not on NPTL, where sem_destroy () is a no-op..
79 .SH SEE ALSO
80 .BR sem_init (3),
81 .BR sem_post (3),
82 .BR sem_wait (3),
83 .BR sem_overview (7)
84 .SH COLOPHON
85 This page is part of release 3.68 of the Linux
86 .I man-pages
87 project.
88 A description of the project,
89 information about reporting bugs,
90 and the latest version of this page,
91 can be found at
92 \%http://www.kernel.org/doc/man\-pages/.