]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sem_destroy.3
Convert to American spelling conventions
[thirdparty/man-pages.git] / man3 / sem_destroy.3
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
4 .\" Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net>
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .TH SEM_DESTROY 3 2006-03-25 "Linux" "Linux Programmer's Manual"
24 .SH NAME
25 sem_destroy \- destroy an unnamed semaphore
26 .SH SYNOPSIS
27 .nf
28 .B #include <semaphore.h>
29 .sp
30 .BI "int sem_destroy(sem_t *" sem );
31 .fi
32 .SH DESCRIPTION
33 .BR sem_destroy ()
34 destroys the unnamed semaphore at the address pointed to by
35 .IR sem .
36
37 Only a semaphore that has been initialized by
38 .BR sem_init (3)
39 should be destroyed using
40 .BR sem_destroy ().
41
42 Destroying a semaphore that other processes or threads are
43 currently blocked on (in
44 .BR sem_wait (3))
45 produces undefined behavior.
46
47 Using a semaphore that has been destroyed produces undefined results,
48 until the semaphore has been reinitialized using
49 .BR sem_init (3).
50 .SH RETURN VALUE
51 .BR sem_destroy ()
52 returns 0 on success;
53 on error, \-1 is returned, and
54 .I errno
55 is set to indicate the error.
56 .SH ERRORS
57 .TP
58 .B EINVAL
59 .I sem
60 is not a valid semaphore.
61 .SH CONFORMING TO
62 POSIX.1-2001.
63 .SH NOTES
64 An unnamed semaphore should be destroyed with
65 .BR sem_destroy ()
66 before the memory in which it is located is deallocated.
67 Failure to do this can result in resource leaks on some implementations.
68 .\" But not on NPTL, where sem_destroy () is a no-op..
69 .SH "SEE ALSO"
70 .BR sem_init (3),
71 .BR sem_post (3),
72 .BR sem_wait (3),
73 .BR sem_overview (7)