1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
|
.\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
.\" Portions Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified 1993-07-28, Rik Faith <faith@cs.unc.edu>
.\" Modified 1993-11-28, Giorgio Ciucci <giorgio@crcc.it>
.\" Modified 1997-01-31, Eric S. Raymond <esr@thyrsus.com>
.\" Modified 2001-02-18, Andries Brouwer <aeb@cwi.nl>
.\" Modified 2002-01-05, 2004-05-27, 2004-06-17,
.\" Michael Kerrisk <mtk-manpages@gmx.net>
.\" Modified 2004-10-11, aeb
.\" Modified, Nov 2004, Michael Kerrisk <mtk-manpages@gmx.net>
.\" Language and formatting clean-ups
.\" Updated shmid_ds structure definitions
.\" Added information on SHM_DEST and SHM_LOCKED flags
.\" Noted that CAP_IPC_LOCK is not required for SHM_UNLOCK
.\" since kernel 2.6.9
.\" Modified, 2004-11-25, mtk, notes on 2.6.9 RLIMIT_MEMLOCK changes
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated Sat Mar 1 16:49:09 JST 1997
.\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified Wed Jun 13 20:53:52 JST 2001
.\" by Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated & Modified Wed Jan 5 03:20:25 JST 2005
.\" by Yuichi SATO <ysato444@yahoo.co.jp>
.\"
.\"WORD: shared memory ͭ
.\"WORD: segment
.\"WORD: owner ͭ
.\"WORD: group 롼
.\"WORD: creator
.\"WORD: super-user ѡ桼
.\"WORD: detach ʬΥ
.\"WORD: attach ղ
.\"WORD: swap å
.\"WORD: identifier ̻
.\"WORD: member С
.\"
.TH SHMCTL 2 2004-11-10 "Linux 2.6.9" "Linux Programmer's Manual"
.SH ̾
shmctl \- ͭ (shared memory) 椹
.SH
.ad l
.B #include <sys/ipc.h>
.sp
.B #include <sys/shm.h>
.sp
.BI "int shmctl(int " shmid ", int " cmd ", struct shmid_ds *" buf );
.ad b
.SH
.BR shmctl ()
ˤꡢƤӽФ϶ͭꡦȤξꡢ
Ȥνͭ (owner)롼 (group) (permission) ꤷꡢ
Ȥ˲ (destroy) Ǥ롣
.PP
.I buf
\fIshmid_ds\fP ¤ΤؤΥݥǤ롣
ι¤Τ <sys/shm.h> ǰʲΤ褦Ƥ
.PP
.in +4n
.nf
struct shmid_ds {
struct ipc_perm shm_perm; /* ͭȵ */
size_t shm_segsz; /* ȤΥ (Х) */
time_t shm_atime; /* Ǹղ (attach) λ */
time_t shm_dtime; /* ǸʬΥ (detach) λ */
time_t shm_ctime; /* ǸѹԤ줿 */
pid_t shm_cpid; /* (creator) PID */
pid_t shm_lpid; /* Ǹ stmat()/shmdt() PID */
shmatt_t shm_nattch; /* ղäƤ */
...
};
.fi
.in -4n
.PP
.I ipc_perm
¤Τ <sys/ipc.h> ǰʲΤ褦Ƥ
(Ĵ줿եɤ
.B IPC_SET
ȤäǽǤ):
.PP
.in +4n
.nf
struct ipc_perm {
key_t key; /* shmget() Ϳ륭 */
uid_t \fBuid\fP; /* ͭԤμ¸ UID */
gid_t \fBgid\fP; /* ͭԤμ¸ GID */
uid_t cuid; /* Ԥμ¸ UID */
gid_t cgid; /* Ԥμ¸ GID */
unsigned short \fBmode\fP; /* \fB\fP + SHM_DEST
SHM_LOCKED ե饰 */
unsigned short seq; /* ֹ */
};
.fi
.in -4n
.PP
.I cmd
Ȥͭͤϰʲ̤:
.br
.TP 12
.B IPC_STAT
.I shmid
˴ϢŤ줿ͥǡ¤Τξ
\fIbuf\fP ǻؤ줿
.I shmid_ds
¤Τ˥ԡ롣
ƤӽФ϶ͭꡦȤФ
ɤ߹ߵĤʤФʤʤ
.TP
.B IPC_SET
.I arg.buf
ˤäƻؤ
.I shmid_ds
¤ΤΤĤΥСͤ
ζͭꡦȤ˴ϢŤ줿ͥǡ¤Τ˽ߡ
.I shm_ctime
С롣
ʲΥեɤѹǤ롣
\fIshm_perms.uid\fP, \fIshm_perms.gid\fP,
\fIshm_perms.mode\fP (κDz 9 ӥå)
ƤӽФץμ¸ UID ͭ
.RI ( shm_perm.uid )
ޤϺ
.RI ( shm_perm.cuid )
Ȱפ뤫ƤӽФøʤФʤʤ
.TP
.B IPC_RMID
Ȥ˲ѤߤΥޡդ롣
ȤϡºݤˤϺǸץȤʬΥ (Ϣ
.I shmid_ds
¤Τ
.I shm_nattch
С 0 ˤʤä) ǤΤ˲롣
ƤӽФϽͭԤԤǤ뤫øʤФʤʤ
Ȥ˲Υޡդȡ
Ϣǡ¤Τˤ
.I shm_perm.mode
եɤ (ɸǤϤʤ)
.B SHM_DEST
ե饰ꤵ롣
Υǡ¤Τ
.B IPC_STAT
Ǽ롣
.PP
ƤӽФϺǽŪˤϥȤ˺줺˲\fIʤФʤʤ\fP
ǤʤСե (fault) 줿ڡ
꤫å (swap) ˻Ĥ³롣
.SS "Linux ˤɲ"
øĸƤӽФϡʲ \fIcmd\fP ͤˤꡢ
ͭꡦȤåפ뤳Ȥ˸ꡢǤǤ:
.br
.TP 12
.B SHM_LOCK
ͭꡦȤåפ뤳Ȥ˸롣
åǽˤʤä塢ƤӽФϡ
¸ߤ뤳Ȥᤵ줿ƤΥڡեȤʤФʤʤ
Ȥåȡ
Ϣǡ¤Τˤ
.I shm_perm.mode
եɤ (ɸŪǤϤʤ)
.B SHM_LOCKED
ե饰ꤵ롣
Υǡ¤Τ
.B IPC_STAT
Ǽ롣
.TP
.B SHM_UNLOCK
ȤΥååסȤ뤳Ȥǽˤ롣
.PP
.BR IPC_INFO ,
.BR SHM_STAT ,
.B SHM_INFO
楳
.BR ipcs (8)
ץˤäƳƤ줿ˤĤƤξ뤿˻Ѥ롣
.SH ֤
0 ֤
顼ξ \-1 ֤
.I errno
Ŭڤꤹ롣
.SH 顼
.TP 11
.B EACCES
\fBIPC_STAT\fP ޤ \fBSHM_STAT\fP ᤵ졢
\fIshm_perm.modes\fP
.I shmid
ؤɤ߹ߥƤ餺
ĸƤӽФץ
.BR CAP_IPC_OWNER
ѥӥƥ (capability) äƤʤ
.TP
.B EFAULT
.I cmd
.B IPC_SET
.B IPC_STAT
ꤵ줿
.I buf
ǻؤƤ륢ɥ쥹˥Ǥʤ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