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 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
|
.\" 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 Sun Nov 28 17:06:19 1993, Rik Faith <faith@cs.unc.edu>
.\" with material from Luigi P. Bai <lpb@softint.com>
.\" Portions Copyright 1993 Luigi P. Bai
.\" Modified Tue Oct 22 22:04:23 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified, 5 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Modified, 19 Sep 2002, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Added SHM_REMAP flag description
.\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Added notes on capability requirements
.\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Language and formatting clean-ups
.\" Changed wording and placement of sentence regarding attachment
.\" of segments marked for destruction
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated 1999-08-15, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified 2002-05-07, Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated & Modified 2003-01-18, Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated & Modified 2005-01-07, Yuichi SATO
.\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16
.\" Updated 2006-04-14, Akihiro MOTOKI, Catch up to LDP man-pages 2.29
.\"
.\"WORD: shared memory ͭ
.\"WORD: segment
.\"WORD: super-user ѡ桼
.\"WORD: detach ʬΥ
.\"WORD: attach ղ
.\"WORD: member С
.\"WORD: implement
.\"WORD: page aligned ڡ˹ä
.\"WORD: unaligned ȿ
.\"WORD: descriptor ǥץ
.\"WORD: parameter ѥ
.\"
.TH SHMOP 2 2004-11-10 "Linux" "Linux Programmer's Manual"
.SH ̾
shmop, shmat, shmdt \- ͭ (shared memory)
.SH
.nf
.B #include <sys/types.h>
.B #include <sys/shm.h>
.fi
.sp
.BI "void *shmat(int " shmid ,
.BI "const void *" shmaddr ,
.BI "int " shmflg );
.sp
.BI "int shmdt(const void *" shmaddr );
.SH
.BR shmat ()
.I shmid
ǻꤵ줿ͭꡦ (shared memory segment)
뤷ץΥɥ쥹֤ղ (attach) 롣
ղä륢ɥ쥹
.I shmaddr
˰ʲΤɤ줫ηǻꤹ:
.LP
.I shmaddr
NULL ʤСƥϥȤղä뤿
Ŭڤ (ѤƤʤ) ɥ쥹롣
.LP
.I shmaddr
NULL Ǥʤ
.B SHM_RND
.I shmflg
˻ꤵƤϡ
.I shmaddr
.B SHMLBA
ܿؤڤΤƤ (rounding down) Τɥ쥹ղä롣
¾ξ
.I shmaddr
ղäԤʤɥ쥹ǡڡؤƤɬפ롣
.PP
.B SHM_RDONLY
.I shmflg
˻ꤵƤϡ
Ȥɤ߹Ѥղä졢ץϤΥȤؤ
ɤ߹ߵĤʤФʤʤ
ǤʤФΥȤɤ߹ߤȽߤΤղä졢
ץϤΥȤɤ߹ߤȽߤεĤɬפ롣
ѤζͭꡦȤȤǰ¸ߤʤ
.PP
(Linux ͭ)
.B SHM_REMAP
ե饰
.I shmflg
˻ꤵ줿ϡ
ȤΥޥåԥ¸Υޥåԥ֤롣
ޥåԥϰϤϡ
.I shmaddr
ϤޤꥻȤΥʬ
(̾
.B EINVAL
顼ϡΥɥ쥹ϰϤ˥ޥåԥ¸ߤ뤿˵)
Υե饰ꤹϡ
.I shmaddr
NULL ǤäƤϤʤʤ
.PP
ƤӽФץ
.BR brk (2)
ͤղäˤäѲʤ
ΥȤϥץλ (exit) 鼫ưŪʬΥ (detach) 롣
ƱȤץΥɥ쥹֤ˡɤ߹Ѥɤ߽ξ
ȤղäǤޤʣղä뤳ȤǤ롣
.PP
.BR shmat ()
϶ͭꡦȤ˴Ϣ
.I shmid_ds
¤
.RB ( shmctl (2)
) ΥСʲΤ褦˹:
.IP
.I shm_atime
ˤϸߤλꤹ롣
.IP
.I shm_lpid
ˤϸƤӽФץΥץ ID ꤹ롣
.IP
.I shm_nattch
1 ä롣
.PP
.BR shmdt ()
ϸƤӽФץΥɥ쥹֤
.I shmaddr
ǻꤵ줿ɥ쥹֤줿ͭꡦȤʬΥ (detach) 롣
ʬΥ붦ͭꡦȤϡ
.I shmaddr
ղäƤΤǤʤФʤʤ
.I shmaddr
ϡղä
.BR shmat ()
֤ͤʤФʤʤ
.PP
.BR shmdt ()
ϤζͭꡦȤ˴Ϣ
.I shmid_ds
¤ΤΥСʲΤ褦˹:
.IP
.I shm_dtime
ˤϸߤλ郎ꤵ롣
.IP
.I shm_lpid
ˤϸƤӽФץΥץ ID ꤵ롣
.IP
.I shm_nattch
1 롣
⤷ 0 ˤʤꡢޡä
ΥȤϺ롣
.PP
.BR fork (2)
塢ҥץղä줿ͭꡦȤѾ롣
.BR exec (2)
塢Ƥղä줿ͭꡦȤϥץʬΥ롣
.BR exit (2)
ˤơƤղä줿ͭꡦȤϥץʬΥ롣
.PP
.SH ֤
.BR shmat ()
ϡ硢
ղä줿ͭꡦȤΥɥ쥹֤
顼ξ硢
.I (void\ *)\ \-1
֤
.I errno
˥顼θͤꤹ롣
.BR shmdt ()
ϡ 0 ֤
顼ξ硢\-1 ֤
.I errno
˥顼θͤꤹ롣
.SH 顼
.BR shmat ()
Ԥ硢
.I errno
˰ʲͤΤɤ줫ꤷ֤:
.TP
.B EACCES
ƤӽФץᤵ줿ղäɬפʵĤʤ
.B CAP_IPC_OWNER
ѥӥƥ (capability) ʤ
.TP
.B EINVAL
.I shmid
ͤǤ롣
.I shmaddr
ͤȿ (unaligned) (Ĥޤꡢڡ˹äƤ餺
\fBSHM_RND\fP ꤵƤʤ) ޤ
Ǥ롣
.I shmaddr
ؤΥȤղä˼Ԥ
ޤ
.B SHM_REMAP
ꤵƤ뤬
.I shmaddr
NULL Ǥä
.TP
.B ENOMEM
ǥץ (descriptor) ڡơ֥ΤΥ
Ƥ뤳ȤǤʤ
.PP
.BR shmdt ()
Ԥ硢
.B EINVAL
ϰʲΤ褦˥åȤ:
.TP
.B EINVAL
.I shmaddr
ղä줿ͭꡦȤ¸ߤʤ
⤷ϡ
.\" 2.6.17-rc1 ʹߤξ
.I shmaddr
ڡ˹äƤʤ
.SH
SVr4, POSIX.1-2001.
.\" SVr4 ˤ¾ EMFILE 顼֤ˤĤƤεҤ롣
SVID 3 (֤Ȼפ)
\fIshmaddr\fP η
.I "char *"
.I "const void *"
ˡ\fIshmat\fP() ֤ͤη
.I "char *"
.I "void *"
ѹ줿
(Linux Ǥ libc4 libc5 Υץȥפ
.I "char *"
Ǥꡢglibc2 Υץȥפ
.I "void *"
Ǥ)
.SH
ͭꥻȤղäΰܿι⤤ˡȤƤϡ
.I shmaddr
NULL ˤ
.BR shmat ()
ѤΤ褤
Τ褦ˡղä붦ͭꥻȤϡ
ץۤʤ̤Υɥ쥹ղä롢Ȥդ뤳ȡ
äƶͭǴݥϡ
Хɥ쥹ǤϤʤ
(ŪˤϥȤγϥɥ쥹)
Хɥ쥹Ǻ٤Ǥ롣
.PP
Linux Ǥ϶ͭꥻȤ˴˺ޡդƤƤ⡢
ζͭꥻȤղä뤳ȤǤ롣
POSIX.1-2001 ǤϤΤ褦ưꤷƤ餺
¾¿μ⤳ݡȤƤʤ
.LP
ʲΥƥࡦѥϡ
.BR shmat ()
ƥࡦ˱ƶ:
.TP 11
.\" FIXME A good explanation of the rationale for the existence
.\" of SHMLBA would be useful here
.B SHMLBA
Ȥζɥ쥹κǾܿڡ˹äƤʤФʤʤ
ߤμǤ
.B SHMLBA
ͤ
.B PAGE_SIZE
Ǥ롣
.\" FIXME That last sentence isn't true for all Linux
.\" architectures (i.e., SHMLBA != PAGE_SIZE for some architectures)
.\" -- MTK, Nov 04
.PP
ߤμǤϡץȤ
ͭꡦȤκ
.RB ( SHMSEG )
˴ؤ¸¤Ϥʤ
.SH Ϣ
.BR brk (2),
.BR mmap (2),
.BR shmctl (2),
.BR shmget (2),
.BR capabilities (7),
.BR svipc (7)
|