1SEM_CLOSE(3P) POSIX Programmer's Manual SEM_CLOSE(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 sem_close — close a named semaphore
14
16 #include <semaphore.h>
17
18 int sem_close(sem_t *sem);
19
21 The sem_close() function shall indicate that the calling process is
22 finished using the named semaphore indicated by sem. The effects of
23 calling sem_close() for an unnamed semaphore (one created by
24 sem_init()) are undefined. The sem_close() function shall deallocate
25 (that is, make available for reuse by a subsequent sem_open() by this
26 process) any system resources allocated by the system for use by this
27 process for this semaphore. The effect of subsequent use of the sema‐
28 phore indicated by sem by this process is undefined. If the semaphore
29 has not been removed with a successful call to sem_unlink(), then
30 sem_close() has no effect on the state of the semaphore. If the
31 sem_unlink() function has been successfully invoked for name after the
32 most recent call to sem_open() with O_CREAT for this semaphore, then
33 when all processes that have opened the semaphore close it, the sema‐
34 phore is no longer accessible.
35
37 Upon successful completion, a value of zero shall be returned. Other‐
38 wise, a value of −1 shall be returned and errno set to indicate the
39 error.
40
42 The sem_close() function may fail if:
43
44 EINVAL The sem argument is not a valid semaphore descriptor.
45
46 The following sections are informative.
47
49 None.
50
52 None.
53
55 None.
56
58 None.
59
61 semctl(), semget(), semop(), sem_init(), sem_open(), sem_unlink()
62
63 The Base Definitions volume of POSIX.1‐2008, <semaphore.h>
64
66 Portions of this text are reprinted and reproduced in electronic form
67 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
68 -- Portable Operating System Interface (POSIX), The Open Group Base
69 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
70 cal and Electronics Engineers, Inc and The Open Group. (This is
71 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
72 event of any discrepancy between this version and the original IEEE and
73 The Open Group Standard, the original IEEE and The Open Group Standard
74 is the referee document. The original Standard can be obtained online
75 at http://www.unix.org/online.html .
76
77 Any typographical or formatting errors that appear in this page are
78 most likely to have been introduced during the conversion of the source
79 files to man page format. To report such errors, see https://www.ker‐
80 nel.org/doc/man-pages/reporting_bugs.html .
81
82
83
84IEEE/The Open Group 2013 SEM_CLOSE(3P)