1sem_close(3C) Standard C Library Functions sem_close(3C)
2
3
4
6 sem_close - close a named semaphore
7
9 #include <semaphore.h>
10
11 int sem_close(sem_t *sem);
12
13
15 The sem_close() function is used to indicate that the calling process
16 is finished using the named semaphore indicated by sem. The effects of
17 calling sem_close() for an unnamed semaphore (one created by
18 sem_init(3C)) are undefined. The sem_close() function deallocates (that
19 is, make available for reuse by a subsequent sem_open(3C) by this
20 process) any system resources allocated by the system for use by this
21 process for this semaphore. The effect of subsequent use of the sema‐
22 phore indicated by sem by this process is undefined. If the semaphore
23 has not been removed with a successful call to sem_unlink(3C), then
24 sem_close() has no effect on the state of the semaphore. If the
25 sem_unlink(3C) function has been successfully invoked for name after
26 the most recent call to sem_open(3C) with O_CREAT for this semaphore,
27 then when all processes that have opened the semaphore close it, the
28 semaphore is no longer be accessible.
29
31 If successful, sem_close() returns 0, otherwise it returns −1 and sets
32 errno to indicate the error.
33
35 The sem_close() function will fail if:
36
37 EINVAL The sem argument is not a valid semaphore descriptor.
38
39
40 ENOSYS The sem_close() function is not supported by the system.
41
42
44 The sem_close() function should not be called for an unnamed semaphore
45 initialized by sem_init(3C).
46
48 See attributes(5) for descriptions of the following attributes:
49
50
51
52
53 ┌─────────────────────────────┬─────────────────────────────┐
54 │ATTRIBUTE TYPE │ATTRIBUTE VALUE │
55 ├─────────────────────────────┼─────────────────────────────┤
56 │Interface Stability │Committed │
57 ├─────────────────────────────┼─────────────────────────────┤
58 │MT-Level │MT-Safe │
59 ├─────────────────────────────┼─────────────────────────────┤
60 │Standard │See standards(5). │
61 └─────────────────────────────┴─────────────────────────────┘
62
64 sem_init(3C), sem_open(3C), sem_unlink(3C), attributes(5), standards(5)
65
67 Solaris 2.6 was the first release to support the Asynchronous Input and
68 Output option. Prior to this release, this function always returned −1
69 and set errno to ENOSYS.
70
71
72
73SunOS 5.11 5 Feb 2008 sem_close(3C)