3 .\" Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
5 .\" @APPLE_LICENSE_HEADER_START@
7 .\" The contents of this file constitute Original Code as defined in and
8 .\" are subject to the Apple Public Source License Version 1.1 (the
9 .\" "License"). You may not use this file except in compliance with the
10 .\" License. Please obtain a copy of the License at
11 .\" http://www.apple.com/publicsource and read it before using this file.
13 .\" This Original Code and all software distributed under the License are
14 .\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 .\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
18 .\" License for the specific language governing rights and limitations
19 .\" under the License.
21 .\" @APPLE_LICENSE_HEADER_END@
28 .Nd initialize and open a named semaphore
30 .Fd #include <semaphore.h>
33 .Fa "const char *name"
38 The parameters "mode_t mode" and "unsigned int value"
41 The named semaphore named
43 is initialized and opened as specified by the argument
45 and a semaphore descriptor is returned to the calling process.
53 .Bd -literal -offset indent -compact
54 O_CREAT create the semaphore if it does not exist
55 O_EXCL error if create and semaphore exists
62 requires an additional two arguments.
64 specifies the permissions for the semaphore as described in
66 and modified by the process' umask value (see
68 The semaphore is created with an initial
70 which must be less than or equal to
75 is specified and the semaphore exists,
77 fails. The check for the existence of the semaphore and the creation
78 of the semaphore are atomic with respect to all processes calling
86 When a new semaphore is created, it is given the user ID and group ID
87 which correspond to the effective user and group IDs of the calling
88 process. There is no visible entry in the file system for the created
89 object in this implementation.
91 The returned semaphore descriptor is available to the calling process
92 until it is closed with
94 or until the caller exits or execs.
96 If a process makes repeated calls to
100 argument, the same descriptor is returned for each successful call,
103 has been called on the semaphore in the interim.
107 fails for any reason, it will return a value of
111 On success, it returns a semaphore descriptor.
113 The named semaphore is opened unless:
116 The required permissions (for reading and/or writing)
117 are denied for the given flags; or
119 is specified, the object does not exist, and permission to
120 create the semaphore is denied.
125 were specified and the semaphore exists.
129 operation was interrupted by a signal.
133 operation is not supported; or
140 The process has already reached its limit for semaphores or file
142 .It Bq Er ENAMETOOLONG
148 Too many semaphores or file descriptors are open on the system.
151 is not set and the named semaphore does not exist.
154 is specified, the file does not exist, and there is insufficient
155 space available to create the semaphore.
169 is specified in the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995).