2 .\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .Nd obtain a semaphore id
37 .Fn semget "key_t key" "int nsems" "int flag"
39 Based on the values of
44 returns the identifier of a newly created or previously existing
47 .\" This is copied verbatim from the shmget manpage. Perhaps
48 .\" it should go in a common manpage, such as .Xr ipc 2
51 is analogous to a filename: it provides a handle that names an
53 There are three ways to specify a key:
56 IPC_PRIVATE may be specified, in which case a new IPC object
59 An integer constant may be specified.
60 If no IPC object corresponding
63 is specified and the IPC_CREAT bit is set in
65 a new one will be created.
70 may be used to generate a key from a pathname.
73 .\" Likewise for this section, except SHM_* becomes SEM_*.
76 The mode of a newly created IPC object is determined by ORing these constants
84 Alter access for user.
86 Read access for group.
88 Alter access for group.
90 Read access for other.
92 Alter access for other.
95 If a new set of semaphores is being created,
97 is used to indicate the number of semaphores the set should contain.
100 may be specified as 0.
105 returns the id of a semaphore set if successful; otherwise, -1
108 is set to indicate the error.
115 .\" ipcperm could fail (we are opening to read and write, as it were)
117 Access permission failure.
119 .\" sysv_sem.c is quite explicit about these, so I'm pretty sure
123 IPC_CREAT and IPC_EXCL were specified, and a semaphore set
128 The number of semaphores requested exceeds the system imposed maximum
131 A semaphore set corresponding to
133 already exists and contains fewer semaphores than
136 A semaphore set corresponding to
142 Insufficiently many semaphores are available.
144 The kernel could not allocate a
145 .Fa "struct semid_ds" .
147 No semaphore set was found corresponding to
149 and IPC_CREAT was not specified.