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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
.\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
.\"
.\" 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 Wed Jul 28 10:57:35 1993, Rik Faith <faith@cs.unc.edu>
.\" Modified Sun Nov 28 16:43:30 1993, Rik Faith <faith@cs.unc.edu>
.\" with material from Giorgio Ciucci <giorgio@crcc.it>
.\" Portions Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
.\" Modified Tue Oct 22 22:03:17 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified, 8 Jan 2003, Michael Kerrisk, <mtk.manpages@gmail.com>
.\" Removed EIDRM from errors - that can't happen...
.\" 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
.\" Added notes on /proc files
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated 1997-03-01, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified 2001-06-03, Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated 2001-12-22, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2002-10-16, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2003-02-23, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-03-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-11-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
.\"
.\"WORD: shared memory ͭ
.\"WORD: segment
.\"WORD: owner ͭ
.\"WORD: group 롼
.\"WORD: world ¾
.\"WORD: creator
.\"WORD: super-user ѡ桼
.\"WORD: detach ʬΥ
.\"WORD: attach ղ
.\"WORD: identifier ̻
.\"WORD: member С
.\"WORD: effective user ID ¸桼ID
.\"WORD: effective group ID ¸롼ID
.\"WORD: policy
.\"WORD: implement
.\"
.TH SHMGET 2 2006-05-02 "Linux" "Linux Programmer's Manual"
.SH ̾
shmget \- ͭꡦȤƤ
.SH
.ad l
.B #include <sys/ipc.h>
.br
.B #include <sys/shm.h>
.sp
.BI "int shmget(key_t " key ", size_t " size ", int " shmflg );
.ad b
.SH
.BR shmget ()
.I key
б붦ͭꡦȤμ̻Ҥ֤
.I key
ͤ
.B IPC_PRIVATE
ξ硢⤷
.I key
б붦ͭꡦȤ¸ߤ
.I shmflg
.B IPC_CREAT
ꤵƤ硢
ͭꡦȤ롣
붦ͭꡦȤϡ
.I size
ͤ
.B PAGE_SIZE
ܿؤڤ夲 (round up) 礭Ȥʤ롣
.PP
.I shmflg
.B IPC_CREAT
.B IPC_EXCL
ξꤵ줿硢
.I key
б붦ͭꡦȤ¸ߤȡ
.BR shmget ()
ϼԤ
.I errno
.B EEXIST
ꤵ (
.BR open (2)
.B O_CREAT | O_EXCL
ꤷưƱǤ)
.PP
.I shmflg
ϰʲƤ鹽:
.TP 12
.B IPC_CREAT
Ȥ롣Υե饰ꤵʤä硢
.BR shmget ()
\fIkey\fP б륻Ȥõ
桼ΥȤ˥Ĥ뤫ɤå롣
.TP
.B IPC_EXCL
\fBIPC_CREAT\fP ȶ˻ѤȤ¸ߤˤ
Ԥ뤳Ȥݾڤ롣
.TP
.I mode_flags
( 9 ӥå)
ͭԡ롼ס¾ (world) ؤεĤꤹ롣
ΥӥåȤ
.BR open (2)
.I mode
ƱƱ̣ġ
ΤȤƥϼ¹ (execute) ĤȤʤ
.TP
.BR SHM_HUGETLB " (Linux 2.6 ʹ)"
"ҥ塼ڡ (huge page)" ȤȤƤ롣
ܺ٤ʾϡͥ롦Υե
.I Documentation/vm/hugetlbpage.txt
ȡ
.TP
.BR SHM_NORESERVE " (Linux 2.6.15 ʹ)"
Υե饰ϡ
.BR mmap (2)
.B MAP_NORESERVE
ե饰Ʊ̤
ΥȤФ륹å֤ͽԤʤ
å֤ͽϡΥȤѹɬ뤳Ȥ
ݾڤ롣å֤ͽԤʤäϡʪ˶
ʤȽ
.B SIGSEGV
ǽ롣
.BR proc (5)
ˤ
.I /proc/sys/vm/overcommit_memory
ե˴ؤ⻲ȤΤȡ
.\" As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
.\" specified.
.PP
ͭꡦȤ˺ݡ
ͭꡦȤƤ 0 ǽ졢
Ϣݻǡ¤
.I shmid_ds
ϰʲΤ褦˽롣
.IP
.I shm_perm.cuid
.I shm_perm.uid
˸ƤӽФץμ¸ (effective) 桼ID ꤹ롣
.IP
.I shm_perm.cgid
.I shm_perm.gid
˸ƤӽФץμ¸롼ID ꤹ롣
.IP
.I shm_perm.mode
β 9 ӥåȤ
.I shmflg
β 9 ӥåȤꤹ롣
.IP
.I shm_segsz
.I size
ͤꤹ롣
.IP
.IR shm_lpid ,
.IR shm_nattch ,
.IR shm_atime ,
.I shm_dtime
0 ꤹ롣
.IP
.I shm_ctime
˸ߤλꤹ롣
.PP
ͭꡦȤ¸ߤ硢Ĥθȡ
˲ (destruction) ޡĤƤʤΥåԤ롣
.SH ֤
硢ͭʥȼ̻
.I shmid
֤롣顼ξ硢 \-1 ֤롣
.SH 顼
Ԥ
.I errno
ʲΤɤ줫ꤵ:
.TP 12
.B EACCES
桼ϤζͭꡦȤؤΥĤ
.B CAP_IPC_OWNER
ѥӥƥäƤʤ
.TP
.B EEXIST
.B IPC_CREAT | IPC_EXCL
ꤵƤΥȤ¸ߤ롣
.TP
.B EINVAL
Ȥ褦Ȥݤ
\fIsize\fP < \fBSHMMIN\fP ޤ \fIsize\fP > \fBSHMMAX\fP Ǥä
⤷ϡꤵ줿б륻Ȥ¸ߤơ
Ȥ褦ȤϤʤä\fIsize\fP ¸ߤ륻Ȥ
礭ä
.TP
.B ENFILE
.\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
ƥΤǥץƤե¤ã
.TP
.B ENOENT
ꤵ줿 \fIkey\fP б륻Ȥ¸ߤ
.B IPC_CREAT
ꤵƤʤä
.TP
.B ENOMEM
Ȥδ (overhead) ˳Ƥ꤬ʤä
.TP
.B ENOSPC
.\" motoki 2005-03-02 -- SHMMNI ΰ̣θư
ƥΤζͭꡦȿ
.RB ( SHMMNI )
ãޤᤵ줿
.I size
ΥȤγƤ
ƥΤζͭꥵ
.RB ( SHMALL )
Ķᤷ
.TP
.B EPERM
.B SHM_HUGETLB
ե饰ꤵ줿ƤӽФˤϸ¤ʤä
.RB ( CAP_IPC_LOCK
ѥӥƥäƤʤä)
.SH
SVr4, POSIX.1-2001.
.\" SVr4 ˤɲä EEXIST 顼֤εҤ롣
.B SHM_HUGETLB
Linux ǤγĥǤꡢܿϤʤ
.SH
.B IPC_PRIVATE
ϥե饰ǤϤʤ
.I key_t
Ǥ롣
̤ͤ
.I key
˻Ѥ줿ϡ
.BR shmget ()
.I shmflg
β 9 ӥåȤƤ̵뤷
() ͭꡦȤ롣
.PP
.BR shmget ()
˱ƶ붦ͭꡦȻ¤ϰʲ̤Ǥ:
.TP 11
.B SHMALL
ƥΤζͭꡦڡκ
(Linux Ǥϡξͤ
.I /proc/sys/kernel/shmall
ͳǻȤꡢѹǤ)
.TP
.B SHMMAX
ͭꡦȤΥХñ̤礭ξ: ˰¸
(Linux Ǥϡξͤ
.I /proc/sys/kernel/shmmax
ͳǻȤꡢѹǤ)
.TP
.B SHMMIN
ͭꡦȤΥХñ̤礭β: ¸
(ߤ 1 ХȤ¼ŪʺǾ
.B PAGE_SIZE
Ǥ)
.TP
.B SHMMNI
ƥΤζͭοξ: ¸
(ߤ 4096Linux 2.3.99 Ǥ 128
Linux Ǥϡξͤ
.I /proc/sys/kernel/shmmni
ͳǻȤꡢѹǤ)
.\" 2.4.x 2.6.8 δ֤ΥͥˤϡSHMMNI Ĥ¿
.\" ȤǤȤХä
.\" /proc ե Linux 2.2 ǤѤǤʤ -- MTK
.PP
ץζͭꡦȤθĿκ
.RB ( SHMSEG )
˴ؤ¤Ϥʤ
.SS Linux Ǥ
С 2.3.30 ޤǤϡLinux
ͽꤵƤ붦ͭꡦȤФ
.BR shmget ()
Ԥ
.B EIDRM
֤Ƥ
.SH Х
.B IPC_PRIVATE
Ȥ̾ΤϤ餯ԤǤ
.B IPC_NEW
ΤˤεǽɽƤ
.SH Ϣ
.BR shmat (2),
.BR shmctl (2),
.BR shmdt (2),
.BR ftok (3),
.BR capabilities (7),
.BR svipc (7)
|