2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH SHMCTL 2 "Apr 10, 2007"
9 shmctl \- shared memory control operations
13 #include <sys/types.h>
17 \fBint\fR \fBshmctl\fR(\fBint\fR \fIshmid\fR, \fBint\fR \fIcmd\fR, \fBstruct shmid_ds *\fR\fIbuf\fR);
23 The \fBshmctl()\fR function provides a variety of shared memory control
24 operations as specified by \fIcmd\fR. The permission required for a shared
25 memory control operation is given as {\fItoken\fR}, where \fItoken\fR is the
26 type of permission needed. The types of permission are interpreted as follows:
41 See the \fIShared Memory Operation Permissions\fR section of \fBIntro\fR(2) for
45 The following operations require the specified tokens:
52 Place the current value of each member of the data structure associated with
53 \fIshmid\fR into the structure pointed to by \fIbuf\fR. The contents of this
54 structure are defined in \fBIntro\fR(2). {\fBREAD\fR}
63 Set the value of the following members of the data structure associated with
64 \fIshmid\fR to the corresponding value found in the structure pointed to by
71 shm_perm.mode /* access permission bits only */
75 This command can be executed only by a process that has appropriate privileges
76 or an effective user \fBID\fR equal to the value of \fBshm_perm.cuid\fR or
77 \fBshm_perm.uid\fR in the data structure associated with \fIshmid\fR.
86 Remove the shared memory identifier specified by \fIshmid\fR from the system.
87 The segment referenced by the identifier will be destroyed when all processes
88 with the segment attached have either detached the segment or exited. If the
89 segment is not attached to any process when \fBIPC_RMID\fR is invoked, it will
90 be destroyed immediately. This command can be executed only by a process that
91 has appropriate privileges or an effective user ID equal to the value of
92 \fBshm_perm.cuid\fR or \fBshm_perm.uid\fR in the data structure associated with
102 Lock the shared memory segment specified by \fIshmid\fR in memory. This command
103 can be executed only by a process that has appropriate privileges.
109 \fB\fBSHM_UNLOCK\fR\fR
112 Unlock the shared memory segment specified by \fIshmid\fR. This command can be
113 executed only by a process that has appropriate privileges.
118 A shared memory segment must be explicitly removed using \fBIPC_RMID\fR before
119 the system can deallocate it and the resources it uses.
123 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
124 returned and \fBerrno\fR is set to indicate the error.
128 The \fBshmctl()\fR function will fail if:
135 The \fIcmd\fR argument is equal to \fBIPC_STAT\fR and \fB{READ}\fR operation
136 permission is denied to the calling process.
145 The \fIbuf\fR argument points to an illegal address.
154 The \fIshmid\fR argument is not a valid shared memory identifier; or the
155 \fIcmd\fR argument is not a valid command or is \fBIPC_SET\fR and
156 \fBshm_perm.uid\fR or \fBshm_perm.gid\fR is not valid.
165 The \fIcmd\fR argument is equal to \fBSHM_LOCK\fR and there is not enough
166 memory, or the operation would exceed a limit or resource control on locked
173 \fB\fBEOVERFLOW\fR\fR
176 The \fIcmd\fR argument is \fBIPC_STAT\fR and \fIuid\fR or \fIgid\fR is too
177 large to be stored in the structure pointed to by \fIbuf\fR.
186 The \fIcmd\fR argument is equal to \fBIPC_RMID\fR or \fBIPC_SET\fR, the
187 effective user ID of the calling process is not equal to the value of
188 \fBshm_perm.cuid\fR or \fBshm_perm.uid\fR in the data structure associated with
189 \fIshmid\fR, and {\fBPRIV_IPC_OWNER\fR} is not asserted in the effective set of
192 The \fIcmd\fR argument is equal to \fBSHM_LOCK\fR or \fBSHM_UNLOCK\fR and
193 {\fBPRIV_PROC_LOCK_MEMORY\fR} is not asserted in the effective set of the
200 See \fBattributes\fR(5) for descriptions of the following attributes:
208 ATTRIBUTE TYPE ATTRIBUTE VALUE
210 Interface Stability Standard
216 \fBipcs\fR(1), \fBIntro\fR(2), \fBshmget\fR(2), \fBshmop\fR(2),
217 \fBattributes\fR(5), \fBprivileges\fR(5), \fBstandards\fR(5)