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
|
.\" 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>
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated Sat Mar 1 16:51:48 JST 1997
.\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\"
.\"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 "November 28, 1993" "Linux 0.99.11" "Linux Programmer's Manual"
.SH ̾
shmget \- ͭꡦ(shared memory segment)Ƥ
.SH
.ad l
.B #include <sys/ipc.h>
.sp
.B #include <sys/shm.h>
.sp
.BI "int shmget(key_t " key ", int " size ", int " shmflg );
.ad b
.SH
.B shmget()
.IR key
ͤ˴Ϣ붦ͭꡦȤμ̻(identifier)
֤⤷
.I key
ͤ
.B IPC_PRIVATE
ξϿͭꡦȤ롣
.I key
ͤ
.B IPC_PRIVATE
ǤʤƤ⡢
.IR key
˶ͭꡦȤƤƤ餺
.I shmflg
.B IPC_CREAT
ꤵƤ(
.IB shmflg &IPC_CREAT
Ǥʤ)ˤ
ͭꡦȤ롣
붦ͭꡦȤϰ
.I size
.BR PAGE_SIZE
ܿؤڤ夲(round up)礭Ȥʤ롣
.PP
.I shmflg
ϰʲƤ鹽:
.TP 12
.B IPC_CREAT
Ȥ롣Υե饰ѤʤäʤС
.B shmget()
\fIkey\fP ˴Ϣ륻ȤĤơ桼Υ
˴Ϣ \fIshmid\fP ȤĤ뤳Ȥå
Ȥ˲(destruction)ޡդƤʤȤݾڤ롣
.TP
.B IPC_EXCL
\fBIPC_CREAT\fP ȶ˻ѤȤ¸ߤˤ
Ԥ뤳Ȥݾڤ롣
.TP
.B mode_flags (lowest 9 bits)
Ͻͭ(owner)롼(group)¾(world)ؤεĤꤹ롣
ΤȤ¹(execute)ĤϥƥˤäƻѤƤʤ
.PP
⤷Ȥ줿硢
.I shmflg
ΥĤϥȤ
.I shmid_ds
¤Τ
.I shm_perm
Сؤȥԡ롣\fIshmid_ds\fP ¤Τ:
.PP
.in +0.5i
.nf
struct shmid_ds {
struct ipc_perm shm_perm; /* operation perms */
int shm_segsz; /* size of segment (bytes) */
time_t shm_atime; /* last attach time */
time_t shm_dtime; /* last detach time */
time_t shm_ctime; /* last change time */
unsigned short shm_cpid; /* pid of creator */
unsigned short shm_lpid; /* pid of last operator */
short shm_nattch; /* no. of current attaches */
};
.fi
.in -0.5i
.PP
.in +0.5i
.nf
struct ipc_perm
{
key_t key;
ushort uid; /* owner euid and egid */
ushort gid;
ushort cuid; /* creator euid and egid */
ushort cgid;
ushort mode; /* lower 9 bits of \fIshmflg\fP */
ushort seq; /* sequence number */
};
.fi
.PP
ˡˡ
ΥƥࡦϥƥζͭꡦȤΥǡ¤
.B shmid_ds
ʲΤ褦˽롣
.IP
.B shm_perm.cuid
.B shm_perm.uid
ˤϸƤӽФץμ¸(effective)桼ID ꤵ롣
.IP
.B shm_perm.cgid
.B shm_perm.gid
ˤϸƤӽФץμ¸(effective)롼ID ꤵ롣
.IP
.B shm_perm.mode
β 9ӥåȤˤ
.IR shmflg
β 9ӥåȤꤵ롣
.IP
.B shm_segsz
ˤ
.IR size
ͤꤵ롣
.IP
.BR shm_lpid ,
.BR shm_nattch ,
.B shm_atime
.B shm_dtime
ˤ
.BR 0
ꤵ롣
.IP
.B shm_ctime
ˤϸ郎ꤵ롣
.PP
˶ͭꡦȤ¸ߤϡĤǧ졢
줬˲ޡƤʤå롣
.PP
.SH ƥࡦ
.TP
.B fork()
.B fork()
θˡҥץղ(attach)줿ͭꡦȤѾ롣
.TP
.B exec()
.B exec()
θˡ
Ƥղä줿ͭꡦȤʬΥ(detach)롣
(˲Ϥʤ)
.TP
.B exit()
.B exit()
ˤơ
Ƥղä줿ͭꡦȤʬΥ롣(˲Ϥʤ)
.PP
.SH ֤
ͭʥȼ̻(identifier)
.IR shmid
֤顼ξ \-1 ֤
.SH 顼
Ԥ
.B errno
ʲΤɤ줫ꤵ:
.TP 12
.B EINVAL
\fBSHMMIN\fP > \fIsize\fP \fIsize\fP > \fBSHMMAX\fP
\fIsize\fP ȤΥ礭֤롣
.TP
.B EEXIST
.B IPC_CREAT | IPC_EXCL
ꤵƤꡢȤ¸ߤ֤롣
.TP
.B EIDRM
ϥȤ˲(destroy)ޡ˺Ƥ֤롣
.TP
.B ENOSPC
Ƥβǽʶͭ ID
.BR "" ( SHMMNI )
Ȥ̤Ƥ䡢ᤵ줿
.I size
ΥȤγƤ
ƥΤζͭ
.BR "" ( SHMALL )
ĶƤ֤롣
.TP
.B ENOENT
Ϳ줿 \fIkey\fP б륻Ȥ¸ߤ
.B IPC_CREAT
ꤵƤʤ֤롣
.TP
.B EACCES
ϥ桼ζͭꡦȤ˥Ĥʤ
֤롣
.TP
.B ENOMEM
ȤκκѤΤΥƤ뤳ȤǤ
ä֤롣
.SH
.B IPC_PRIVATE
ϥե饰ǤϤʤ
.B key_t
μǤ롣
̤ͤ
.IR key
˻Ѥ줿ϡƥࡦ
.I shmflg
β 9ӥåȤƤ̵뤷
()ͭꡦȤ롣
.PP
ʲ
.B shmget
˱ƶ붦ͭꡦȻ¤Ǥ:
.TP 11
.B SHMALL
ƥΤζͭꡦڡκ: ˰¸
.TP
.B SHMMAX
ͭꡦȤΥХñ̤礭ξ: ¸
(ߤ 4M)
.TP
.B SHMMIN
ͭꡦȤΥХñ̤礭β: ¸
(ߤ 1ХȤ¸ŪʺǾ
.B PAGE_SIZE
Ǥ롣)
.TP
.B SHMMNI
ƥΤζͭοξ: ¸(ߤ 4096)
.PP
μǤϥץζͭꡦȤ
Ѥξ
.RB ( SHMSEG )
¸ߤʤ
.SH Х
.B IPC_PRIVATE
ѤȤƤ⡢Ƥ줿ͭꡦȤ
¾Υץ뤳Ȥ˸뤳ȤϤǤʤ
.PP
եƱͤˡΤȤץζͭꡦȤؤ
¾Ūʥݾڤͭˡ¸ߤʤ
.B IPC_CREAT
.B IPC_EXCL
ξ
.I shmflg
ꤹ뤳Ȥ()
ͭꡦȤ뤳ȤΤߤݾڤ
ΥȤؤ¾ŪʥݾڤΤǤϤʤ
.SH
SVr4, SVID. SVr4 ˤ¾ EEXIST 顼֤εҤ롣
SVr4 SVID ˤ EIDRM ˤĤƤεҤϤʤ
.SH Ϣ
.BR ftok (3),
.BR ipc (5),
.BR shmctl (2),
.BR shmat (2),
.BR shmdt (2)
|