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
|
.\" 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 Tue Oct 22 17:54:56 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 1 Jan 2002, Martin Schulze <joey@infodrom.org>
.\" Modified 4 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
.\" 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
.\" Rewrote BUGS note about semget()'s failure to initialize
.\" semaphore values
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2003-04-08, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-03-01, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2006-07-20, Akihiro MOTOKI, LDP v2.36
.\"
.\"WORD: semaphore ޥե
.\"WORD: identifier ̻
.\"WORD: owner ͭ
.\"WORD: group 롼
.\"WORD: other ¾
.\"WORD: effective user ID ¸桼 ID
.\"WORD: effective group ID ¸롼 ID
.\"WORD: calling process ƤӽФΥץ
.\"WORD: process ץ
.\"WORD: policy
.\"WORD: structure ¤
.\"WORD: initialize
.\"WORD: system call ƥࡦ
.\"
.TH SEMGET 2 2004-05-27 "Linux" "Linux Programmer's Manual"
.SH ̾
semget \- ޥեμ̻Ҥ
.SH
.nf
.B
#include <sys/types.h>
.B
#include <sys/ipc.h>
.B
#include <sys/sem.h>
.fi
.sp
.BI "int semget(key_t " key ,
.BI "int " nsems ,
.BI "int " semflg );
.SH
.BR semget ()
ƥॳϡ
.I key
б륻ޥե (semaphore set)
̻ (identifier) ֤
.I key
ͤ
.B IPC_PRIVATE
ξ硢⤷
.I semflg
.B IPC_CREAT
ꤵƤơ
.I key
б륻ޥե礬¸ߤʤ硢
.I nsems
ĤΥޥեʤ뿷礬롣
.PP
.I semflg
.B IPC_CREAT
.B IPC_EXCL
ξꤵ줿硢
.I key
б륻ޥե礬¸ߤȡ
.BR semget ()
ϼԤ
.I errno
.B EEXIST
ꤵ
(
.BR open (2)
.B O_CREAT | O_EXCL
ꤵ줿ưƱǤ)
.PP
ޥեˡ
.I semflg
β 9 ӥåȤϡΥޥե (ͭ (owner)롼 (group)
¾ (others) Ф) ĤȤƻѤ롣
ΥӥåȤ
.BR open (2)
ΰ
.I mode
ƱƱ̣Ǥ
(â¹ (execute) ĤϥޥեǤϰ̣
(write) Ĥϥޥեͤѹ (alter) ĤȤƵǽ)
.PP
줿ޥեγƥޥեͤǤ
( POSIX.1-2001 Ƥ)
Linux ¾¿μƱͤ˥ޥեͤ 0 ˽뤬
ܿθץꥱǤϤưˤ٤ǤϤʤ
ץꥱŪ˥ޥե˾ͤǽ٤Ǥ롣
.\" In truth, every one of the many implementations that I've tested sets
.\" the values to zero, but I suppose there is/was some obscure
.\" implementation out there that does not.
.PP
Υޥեݡ
.BR semget ()
ϥޥեξݻǡ¤
.I semid_ds
Τ褦˽
.RI ( semid_ds
ˤĤƤ
.BR semctl (2)
):
.IP
.I sem_perm.cuid
.I sem_perm.uid
ˡƤӽФΥץμ¸ (effective) 桼 ID ꤹ롣
.IP
.I sem_perm.cgid
.I sem_perm.gid
ˡƤӽФΥץμ¸ (effective) 롼 ID ꤹ롣
.IP
.I sem_perm.mode
β 9 ӥåȤ
.I semflg
β 9 ӥåȤꤹ롣
.IP
.I sem_nsems
.I nsems
ͤꤹ롣
.IP
.I sem_otime
0 ꤹ롣
.IP
.I sem_ctime
˸ߤλꤹ롣
.PP
ޥեκԤʤϡ
.I nsems
(don't care ̣) 0 ꤷƤ褤
Ǥʤϡ
.I nsems
0 礭ͤǤʤФʤ餺ޥե礢Υޥեκ
.RB ( SEMMSL )
ʲǤʤФʤʤ
.PP
ޥե礬¸ߤϡĤθԤ롣
.\" ˲ (destruction) ޡʤå롣
.SH ֤
硢ޥեμ̻ () ֤ͤȤʤ롣
Ԥ \-1 ֤졢
.I errno
˥顼ͤꤵ롣
.SH 顼
Ԥ硢
.I errno
ˤϰʲͤΤ줫Ĥꤵ:
.TP 11
.B EACCES
.I key
б륻ޥե¸ߤ뤬
ƤӽФΥץϤνؤΥĤʤ
.B CAP_IPC_OWNER
ѥӥƥäƤʤ
.TP
.B EEXIST
.I key
б륻ޥե礬¸ߤ
.I semflg
ˤ
.B IPC_CREAT
.B IPC_EXCL
ꤵƤ
.\" .TP
.\" .B EIDRM
.\" ޥե˺ (delete) ޡĤƤ롣
.TP
.B EINVAL
.I nsems
0 꾮ޥե礢Υޥեκ
.RB ( SEMMSL )
礭
ޤϡ
.I key
б륻ޥե礬¸ߤ
.I nsems
νΥޥե礭
.TP
.B ENOENT
.I key
б륻ޥե礬¸ߤ
.I semflg
.B IPC_CREAT
ꤵƤ⤤ʤ
.TP
.B ENOMEM
ޥե褦Ȥǡ¤Τ
Τ˽ʬʥ꤬ƥ¸ߤʤ
.TP
.B ENOSPC
ޥե褦ȤȡƥΥޥե
.RB ( SEMMNI )
ƥΤΥޥեκ
.RB ( SEMMNS )
Τ줫ĶƤޤ
.SH
SVr4, POSIX.1-2001.
.\" SVr4 ˤϡɲä EFBIG, E2BIG, EAGAIN, ERANGE, EFAULT
.\" Υ顼֤ˤĤƤεҤ롣
.SH
.B IPC_PRIVATE
ϥե饰եɤ˻ꤹΤǤϤʤ
.I key_t
Ǥ롣
̤ͤ
.I key
˻ꤵȡ
.BR semget ()
.I semflg
β 9 ӥåȰʳ̵뤷
() ޥե롣
.PP
ޥեΥ˴ؤ¤Τ
.BR semget ()
˱ƶڤܤΤʲ˵:
.TP 11
.B SEMMNI
ƥΤΥޥեκ: ˰¸
(Linux Ǥϡͤ
.I /proc/sys/kernel/sem
4եɤбɤ߽ФѹǤ)
.\" /proc ե Linux 2.2 ǤѤǤʤ -- MTK
.TP
.B SEMMSL
semid Υޥեκ: ¸
(Linux Ǥϡͤ
.I /proc/sys/kernel/sem
1եɤбɤ߽ФѹǤ)
.TP
.B SEMMNS
ƥΤΥޥեκ: ˰¸
(Linux Ǥϡͤ
.I /proc/sys/kernel/sem
2եɤбɤ߽ФѹǤ)
.B SEMMSL * SEMMNI
礭ͤϰ̣ʤ
.SH Х
.B IPC_PRIVATE
Ȥ̾ΤϤ餯ԤǤ
.B IPC_NEW
ΤˤεǽɽƤ
.LP
ޥեΥޥե
.BR semget ()
ǤϽʤ
.\" ºݤ Linux Ǥϥޥե 0 ˽뤬
.\" POSIX.1-2001 ǤϤʤ뤳ȤꤷƤǤϤʤΤǡ
.\" ܿθȤˤϤˤƤϤʤ
ΥޥեˤϡޥեФ
.BR semctl (2)
Ȥä
.B SETVAL
.B SETALL
¹Ԥɬפ롣
(ʣս꤫饻ޥեԤ̤Ǥϡ
ïǽ˽Ф褤ʬʤ
ξˤϡ
.BR semctl (2)
.B IPC_STAT
ǼǤ륻ޥեΥǡ¤Τ
.I sem_otime
0 ʳˤʤäƤ뤫åФ褤)
.SH Ϣ
.BR semctl (2),
.BR semop (2),
.BR ftok (3),
.BR capabilities (7),
.BR sem_overview (7),
.BR svipc (7)
|