Debian Codegraph @

upstream/debian-unstable/man3/sem_close.3

raw
1 '\" t
2 .\" Copyright 2006, Michael Kerrisk <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH sem_close 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 sem_close \- close a named semaphore
10 .SH LIBRARY
11 POSIX threads library
12 .RI ( libpthread ,\~ \-lpthread )
13 .SH SYNOPSIS
14 .nf
15 .B #include <semaphore.h>
16 .P
17 .BI "int sem_close(sem_t *" sem );
18 .fi
19 .SH DESCRIPTION
20 .BR sem_close ()
21 closes the named semaphore referred to by
22 .IR sem ,
23 allowing any resources that the system has allocated to
24 the calling process for this semaphore to be freed.
25 .SH RETURN VALUE
26 On success
27 .BR sem_close ()
28 returns 0; on error, \-1 is returned, with
29 .I errno
30 set to indicate the error.
31 .SH ERRORS
32 .TP
33 .B EINVAL
34 .I sem
35 is not a valid semaphore.
36 .SH ATTRIBUTES
37 For an explanation of the terms used in this section, see
38 .BR attributes (7).
39 .TS
40 allbox;
41 lbx lb lb
42 l l l.
43 Interface Attribute Value
44 T{
45 .na
46 .nh
47 .BR sem_close ()
48 T} Thread safety MT-Safe
49 .TE
50 .SH STANDARDS
51 POSIX.1-2008.
52 .SH HISTORY
53 POSIX.1-2001.
54 .SH NOTES
55 All open named semaphores are automatically closed on process
56 termination, or upon
57 .BR execve (2).
58 .SH SEE ALSO
59 .BR sem_getvalue (3),
60 .BR sem_open (3),
61 .BR sem_post (3),
62 .BR sem_unlink (3),
63 .BR sem_wait (3),
64 .BR sem_overview (7)