]>
Commit | Line | Data |
---|---|---|
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 |
8 | sem_destroy \- destroy an unnamed semaphore | |
ae0f7f24 AC |
9 | .SH LIBRARY |
10 | POSIX 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 () | |
20 | destroys the unnamed semaphore at the address pointed to by | |
21 | .IR sem . | |
847e0d88 | 22 | .PP |
d9bfdb9c | 23 | Only a semaphore that has been initialized by |
2c731798 MK |
24 | .BR sem_init (3) |
25 | should be destroyed using | |
26 | .BR sem_destroy (). | |
847e0d88 | 27 | .PP |
c13182ef | 28 | Destroying a semaphore that other processes or threads are |
2c731798 MK |
29 | currently blocked on (in |
30 | .BR sem_wait (3)) | |
d9bfdb9c | 31 | produces undefined behavior. |
847e0d88 | 32 | .PP |
2c731798 | 33 | Using a semaphore that has been destroyed produces undefined results, |
d9bfdb9c | 34 | until the semaphore has been reinitialized using |
2c731798 MK |
35 | .BR sem_init (3). |
36 | .SH RETURN VALUE | |
37 | .BR sem_destroy () | |
c13182ef | 38 | returns 0 on success; |
2c731798 | 39 | on error, \-1 is returned, and |
c13182ef | 40 | .I errno |
2c731798 MK |
41 | is set to indicate the error. |
42 | .SH ERRORS | |
43 | .TP | |
44 | .B EINVAL | |
45 | .I sem | |
46 | is not a valid semaphore. | |
4ef41a41 | 47 | .SH ATTRIBUTES |
24454159 PH |
48 | For 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 |
53 | allbox; | |
c466875e | 54 | lbx lb lb |
24454159 PH |
55 | l l l. |
56 | Interface Attribute Value | |
57 | T{ | |
4ef41a41 | 58 | .BR sem_destroy () |
24454159 PH |
59 | T} Thread safety MT-Safe |
60 | .TE | |
c466875e MK |
61 | .hy |
62 | .ad | |
63 | .sp 1 | |
3113c7f3 | 64 | .SH STANDARDS |
805eb9cc | 65 | POSIX.1-2001, POSIX.1-2008. |
2c731798 MK |
66 | .SH NOTES |
67 | An unnamed semaphore should be destroyed with | |
68 | .BR sem_destroy () | |
69 | before the memory in which it is located is deallocated. | |
70 | Failure 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) |