1 .\" $NetBSD: shmctl.2,v 1.21 2010/03/22 19:30:55 joerg Exp $
3 .\" Copyright (c) 1995 Frank van der Linden
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.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed for the NetBSD Project
17 .\" by Frank van der Linden
18 .\" 4. The name of the author may not be used to endorse or promote products
19 .\" derived from this software without specific prior written permission
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .Nd shared memory control operations
43 .Fn shmctl "int shmid" "int cmd" "struct shmid_ds *buf"
47 system call performs control operations on the shared memory segment
51 Each shared memory segment has a
53 structure associated with it which contains the following members:
55 struct ipc_perm shm_perm; /* operation permissions */
56 size_t shm_segsz; /* size of segment in bytes */
57 pid_t shm_lpid; /* pid of last shm op */
58 pid_t shm_cpid; /* pid of creator */
59 shmatt_t shm_nattch; /* # of current attaches */
60 time_t shm_atime; /* last shmat() time */
61 time_t shm_dtime; /* last shmdt() time */
62 time_t shm_ctime; /* last change by shmctl() */
67 structure used inside the
69 structure is defined in
71 and contains the following members:
73 uid_t cuid; /* creator user id */
74 gid_t cgid; /* creator group id */
75 uid_t uid; /* user id */
76 gid_t gid; /* group id */
77 mode_t mode; /* permission (lower 9 bits) */
80 The operation to be performed by
85 .Bl -tag -width IPC_RMIDX
87 Gather information about the shared memory segment and place it in the
88 structure pointed to by
96 fields in the structure associated with
98 The values are taken from the corresponding fields in the structure
101 This operation can only be executed by the super-user, or a process that
102 has an effective user id equal to either
106 in the data structure associated with the shared memory segment.
108 Remove the shared memory segment specified by
110 and destroy the data associated with it.
111 Only the super-user or a process with an effective uid equal to the
115 values in the data structure associated with the segment can do this.
117 Lock the shared memory segment specified by
120 This operation can only be executed by the super-user.
122 Unlock the shared memory segment specified by
124 This operation can only be executed by the super-user.
127 The read and write permissions on a shared memory identifier
128 are determined by the
130 field in the same way as is
133 but the effective uid can match either the
138 effective gid can match either
143 Upon successful completion, a value of 0 is returned.
144 Otherwise, \-1 is returned and the global variable
146 is set to indicate the error.
154 and the caller has no read permission for this shared memory segment.
157 specifies an invalid address.
160 is not a valid shared memory segment identifier.
163 is not a valid command.
169 and there is not enough physical memory.
176 and the caller is not the super-user, nor does
177 the effective uid match either the
181 fields of the data structure associated with the shared memory segment.
183 An attempt was made to increase the value of
187 but the caller is not the super-user.
195 and the caller is not the super-user.
205 system call conforms to
208 Shared memory segments appeared in the first release of