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.
26 .\" $FreeBSD: src/lib/libc/sys/semctl.2,v 1.9.2.6 2002/03/11 08:37:47 maxim Exp $
27 .\" $DragonFly: src/lib/libc/sys/semctl.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
29 .Dd September 12, 1995
34 .Nd control operations on a semaphore set
42 .Fn semctl "int semid" "int semnum" "int cmd" ...
45 performs the operation indicated by
47 on the semaphore set indicated by
50 .Fa "union semun arg" ,
51 is required for certain values of
53 For the commands that use the
57 is defined as follows:
63 int val; /* value for SETVAL */
64 struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
65 u_short *array; /* array for GETALL & SETALL */
69 Commands are performed as follows:
71 .\" This section based on Stevens, _Advanced Programming in the UNIX
74 .Bl -tag -width IPC_RMIDXXX
76 Fetch the semaphore set's
77 .Fa "struct semid_ds" ,
78 storing it in the memory pointed to by
86 members of the semaphore set's
88 to match those of the struct pointed to by
90 The calling process's effective uid must
95 or it must have superuser privileges.
97 Immediately removes the semaphore set from the system. The calling
98 process's effective uid must equal the semaphore set's
102 or the process must have superuser privileges.
104 Return the value of semaphore number
107 Set the value of semaphore number
112 Return the pid of the last process to perform an operation on
116 Return the number of processes waiting for semaphore number
118 value to become greater than its current value.
120 Return the number of processes waiting for semaphore number
124 Fetch the value of all of the semaphores in the set into the
128 Set the values of all of the semaphores in the set to the values
129 in the array pointed to by
134 .Fa "struct semid_ds"
135 is defined as follows:
138 .\" Taken straight from <sys/sem.h>.
141 struct ipc_perm sem_perm; /* operation permission struct */
142 struct sem *sem_base; /* pointer to first semaphore in set */
143 u_short sem_nsems; /* number of sems in set */
144 time_t sem_otime; /* last operation time */
145 long sem_pad1; /* SVABI/386 says I need this here */
146 time_t sem_ctime; /* last change time */
147 /* Times measured in secs since */
148 /* 00:00:00 GMT, Jan. 1, 1970 */
149 long sem_pad2; /* SVABI/386 says I need this here */
150 long sem_pad3[4]; /* SVABI/386 says I need this here */
157 .Dv GETVAL , GETPID , GETNCNT
161 returns the corresponding value; otherwise, 0 is returned.
162 On failure, -1 is returned, and
164 is set to indicate the error.
170 No semaphore set corresponds to
174 is not in the range of valid semaphores for given semaphore set.
176 The calling process's effective uid does not match the uid of
177 the semaphore set's owner or creator.
179 Permission denied due to mismatch between operation and mode of