1 .\" $OpenBSD: shmctl.2,v 1.2 1996/10/08 01:20:15 michaels Exp $
2 .\" $NetBSD: shmctl.2,v 1.1 1995/10/16 23:49:30 jtc Exp $
4 .\" Copyright (c) 1995 Frank van der Linden
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed for the NetBSD Project
18 .\" by Frank van der Linden
19 .\" 4. The name of the author may not be used to endorse or promote products
20 .\" derived from this software without specific prior written permission
22 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 .Nd shared memory control operations
40 .Fd #include <sys/types.h>
41 .Fd #include <sys/ipc.h>
42 .Fd #include <sys/msg.h>
44 .Fn shmctl "int shmid" "int cmd" "struct shmid_ds *buf"
48 system call performs some control operations on the shared memory area
51 Each shared memory segment has a data structure associated with it,
52 parts of which may be altered by
54 and parts of which determine the actions of
56 This structure is defined as follows in
60 struct ipc_perm shm_perm; /* operation permissions */
61 int shm_segsz; /* size of segment in bytes */
62 pid_t shm_lpid; /* pid of last shm op */
63 pid_t shm_cpid; /* pid of creator */
64 short shm_nattch; /* # of current attaches */
65 time_t shm_atime; /* last shmat() time*/
66 time_t shm_dtime; /* last shmdt() time */
67 time_t shm_ctime; /* last change by shmctl() */
68 void *shm_internal; /* sysv stupidity */
75 structure used inside the
79 structure is defined in
84 ushort cuid; /* creator user id */
85 ushort cgid; /* creator group id */
86 ushort uid; /* user id */
87 ushort gid; /* group id */
88 ushort mode; /* r/w permission (see chmod(2)) */
89 ushort seq; /* sequence # (to generate unique msg/sem/shm id) */
90 key_t key; /* user specified msg/sem/shm key */
93 The operation to be performed by
98 .Bl -tag -width IPC_RMIDX
100 Gather information about the shared memory segment and place it in the
101 structure pointed to by
109 fields in the structure associated with
111 The values are taken from the corresponding fields in the structure
114 This operation can only be executed by the super-user, or a process that
115 has an effective user id equal to either
119 in the data structure associated with the shared memory segment.
121 Remove the shared memory segment specified by
123 and destroy the data associated with it. Only the super-user or a process
124 with an effective uid equal to the
128 values in the data structure associated with the queue can do this.
130 The read and write permissions on a shared memory identifier
131 are determined by the
133 field in the same way as is
136 but the effective uid can match either the
141 effective gid can match either
146 Upon successful completion, a value of 0 is returned. Otherwise, -1 is
147 returned and the global variable
149 is set to indicate the error.
156 is equal to IPC_SET or IPC_RMID and the caller is not the super-user, nor does
157 the effective uid match either the
161 fields of the data structure associated with the shared memory segment.
162 An attempt is made to increase the value of
165 but the caller is not the super-user.
167 The command is IPC_STAT
168 and the caller has no read permission for this shared memory segment.
171 is not a valid shared memory segment identifier.
173 is not a valid command.
176 specifies an invalid address.