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
|
'\" t
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" 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.
.\"
.\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
.\" Translated 2006-03-13, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2006-07-20, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
.\" Updated 2009-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.19
.\"
.\"WORD: message queue descriptor å塼һ
.\"WORD: message queue description å塼
.\"
.TH MQ_OVERVIEW 7 2009-02-25 "Linux" "Linux Programmer's Manual"
.SH ̾
mq_overview \- POSIX å塼γ
.SH
POSIX å塼Ѥȡץ֤
åηǤΥǡΤԤȤǤ롣
API System V å塼 API
.RB ( msgget (2),
.BR msgsnd (2),
.BR msgrcv (2)
ʤ) ȤϰۤʤΤƱͤεǽ롣
å塼κȥץ
.BR mq_open (3)
ȤäƹԤδؿ
.I å塼һ (message queue descriptor)
.RI ( mqd_t )
֤ʹߤΥǤϡץ줿å塼
.I å塼һ
ȤäƻȤ롣
ƥå塼
.I /somename
η̾Ƕ̤뤳ȤǤ롣
̾ϡ
.B NAME_MAX
(ʤ 255) ʸ NULL ü줿ʸǡ
åǻϤޤꡢåʳʸ 1 ʸʾ³Ǥ롣
.BR mq_open (3)
Ʊ̾ϤȤǡ2ĤΥץƱΥ塼
뤳ȤǤ롣
åΥ塼ؤ
.BR mq_send (3)
.BR mq_receive (3)
ȤäƹԤץ塼λѤȤˤϡ
.BR mq_close (3)
Ȥäƥ塼롣塼ϤפȤʤäˤϡ
.BR mq_unlink (3)
Ȥäƥ塼Ǥ롣塼°
.BR mq_getattr (3)
ǼǤ (¤Ϥ뤬)
.BR mq_setattr (3)
ѹǤ롣
.BR mq_notify (3)
ȤȤǡΥ塼ؤΥåƱ
Τ褦᤹뤳ȤǤ롣
å塼һҤ
.I "ץå塼 (open message queue description)"
ؤλȤǤ
.RB ( open (2)
⻲)
.BR fork (2)
¹ԸϡҥץϿƥץΥå塼һҤΥԡѾ롣
εһҤϡƥץб뵭һҤƱץå塼
ҤȤƤ롣ƥץȻҥץб뵭һҤϡե饰
.RI ( mq_flags )
ͭ롣ʤʤ顢ե饰ϥץå塼Ҥ
ϢդƤ뤫Ǥ롣
ƥåˤϤ줾
.I ͥ (priority)
ꡢåμץؤϾ
ͥ٤ι⤤å˹Ԥ롣
åͥ٤ 0 (ͥ)
.I sysconf(_SC_MQ_PRIO_MAX)\ -\ 1
(ͥ) ͤġ
Linux Ǥϡ
.I sysconf(_SC_MQ_PRIO_MAX)
32768 ֤
POSIX.1-2001 ᤵƤΤ 0 31 ޤǤͥ٤
뤳ȤǤꡢˤäƤϤϰϤͥ٤
бƤʤ
.PP
λĤǤϡPOSIX å塼 Linux μξܺ
ˤĤ롣
.SS 饤֥ꥤեȥƥॳ
ۤȤɤξ硢嵭
.B mq_*()
饤֥ꥤեϡƱ̾βؤΥƥॳ
ȤäƼƤ롣ȤߤˤƤϤޤʤΤ
ʲɽ˼
.in +4n
.TS
lB lB
l l.
Library interface System call
mq_close(3) close(2)
mq_getattr(3) mq_getsetattr(2)
mq_notify(3) mq_notify(2)
mq_open(3) mq_open(2)
mq_receive(3) mq_timedreceive(2)
mq_send(3) mq_timedsend(2)
mq_setattr(3) mq_getsetattr(2)
mq_timedreceive(3) mq_timedreceive(2)
mq_timedsend(3) mq_timedsend(2)
mq_unlink(3) mq_unlink(2)
.TE
.in
.SS С
Linux Ǥ POSIX å塼ϥͥ 2.6.6 ʹߤǥݡȤƤ롣
glibc ǤϥС 2.3.4 ʹߤǥݡȤƤ롣
.SS ͥ
POSIX å塼ΥݡȤϡͥ (configuration)
ץ
.B CONFIG_POSIX_MQUEUE
ǽǤ롣ΥץϥǥեȤǤͭǤ롣
.SS ³
POSIX å塼ϥͥݻ롣
.BR mq_unlink (3)
ǺʤСå塼
ƥबåȥޤ¸ߤ³롣
.SS
POSIX å塼 API Ѥץ
.I cc \-lrt
ǥѥ뤷ꥢ륿饤֥
.I librt
ȥʤФʤʤ
.SS /proc ե
ʲΥեȤäơPOSIX å塼륫ͥ
̤¤뤳ȤǤ롣
.TP
.I /proc/sys/fs/mqueue/msg_max
ΥեȤäơĤΥ塼åκ
ͤȤѹǤ롣ͤϡ
.BR mq_open (3)
Ϥ
.I attr\->mq_maxmsg
ФͤȤƵǽ롣
.I msg_max
ΥǥեͤӺǾͤ 10 Ǥ;
¤ϡߤθ͡
.RB ( HARD_MAX )
.IR "(131072\ /\ sizeof(void\ *))"
(Linux/86 Ǥ 32768) Ǥ롣
ξ¤øץ
.RB ( CAP_SYS_RESOURCE )
Ǥ̵뤵뤬ߤθͤˤ¤
ɤʾˤǤŬѤ롣
.TP
.I /proc/sys/fs/mqueue/msgsize_max
ΥեȤäơåκ祵ξͤ
ȤѹǤ롣
ͤϡ
.BR mq_open (3)
Ϥ
.I attr\->mq_msgsize
ФͤȤƵǽ롣
.I msgsize_max
ΥǥեͤӺǾͤ 8192 ХȤǤ;
¤
.B INT_MAX
(Linux/86 Ǥ 2147483647) Ǥ롣
ξ¤øץ
.RB ( CAP_SYS_RESOURCE )
Ǥ̵뤵롣
.TP
.I /proc/sys/fs/mqueue/queues_max
ΥեȤäơ뤳ȤǤå塼ο
Ф륷ƥΤǤ¤ȤѹǤ롣
٤ξ¤ãȡå塼ǤΤ
øץ
.RB ( CAP_SYS_RESOURCE )
Ȥʤ롣
.I queues_max
Υǥեͤ 256 Ǥꡢ
0 INT_MAX ϰϤǤդͤѹ뤳ȤǤ롣
.SS
.B RLIMIT_MSGQUEUE
ϡץμ UID бå塼
֤̤Фƾ¤ꤹ롣
.BR getrlimit (2)
ȡ
.SS å塼ե륷ƥΥޥ
Linux Ǥϡå塼ϲۥե륷ƥ˺
(¾μǤƱͤεǽƤΤ⤢뤬
ܺ٤ϰäƤ)
ʲΥޥɤȤȤǡΥե륷ƥޥȤǤ:
.in +4n
.nf
.RB "$" " mkdir /dev/mqueue"
.RB "$" " mount \-t mqueue none /dev/mqueue"
.fi
.in
ޥȤǥ쥯ȥΥƥåӥå (sticky bit)
ưŪ˥Ȥʤ롣
å塼ե륷ƥΥޥȸϡեФ
̾Ȥޥ (㤨
.BR ls (1)
.BR rm (1))
ȤäơƥΥå塼ɽ
Ǥ롣
ǥ쥯ȥγƥեƤ 1ԤǤꡢ
塼˴ؤɽ롣
.in +4n
.nf
.RB "$" " ls /dev/mqueue/mymq"
QSIZE:129 NOTIFY:2 SIGNO:0 NOTIFY_PID:8260
.RB "$" " mount \-t mqueue none /dev/mqueue"
.fi
.in
ƥեɤξܺ٤ϰʲ̤Ǥ:
.TP
.B QSIZE
塼äƤåιץХȿ
.TP
.B NOTIFY_PID
ͤ 0 ʳξ硢ͤ PID ĥץ
.BR mq_notify (3)
ȤäơƱΥåΤԤ褦ꤷȤ
ɤΤ褦ΤԤ뤫ϡʲΥեɤˤꤵ롣
.TP
.B NOTIFY
ˡ:
0
.BR SIGEV_SIGNAL ;
1
.BR SIGEV_NONE ;
2
.B SIGEV_THREAD
.TP
.B SIGNO
.B SIGEV_SIGNAL
˻Ѥ륷ʥֹ档
.SS å塼һҤΥݡ
Linux Ǥϡå塼һҤϼºݤϥե뵭һ (file descriptor)
Ǥꡢ
.BR select (2),
.BR poll (2),
.BR epoll (7)
Ȥäƴƻ뤹뤳ȤǤ롣
εǽΰܿϤʤ
.SH
POSIX.1-2001.
.SH
System V å塼
.RB ( msgget (2),
.BR msgsnd (2),
.BR msgrcv (2)
ʤ) ϥץ֤ǥåꤹ뤿θŤ API Ǥ롣
POSIX å塼 System V å塼⤦ޤ
߷פ줿եƤ롣
ǡPOSIX å塼 System V å塼٤
ѤǤ륷ƥबʤ (äˡŤƥǤϾʤ)
ߤΤȤ (С 2.6.26 )
Linux POSIX å塼Ф륢ꥹ (ACL)
бƤʤ
.SH
ƼΥå塼ؿѤ㤬
.BR mq_notify (3)
˵ܤƤ롣
.SH Ϣ
.BR getrlimit (2),
.BR mq_getsetattr (2),
.BR poll (2),
.BR select (2),
.BR mq_close (3),
.BR mq_getattr (3),
.BR mq_notify (3),
.BR mq_open (3),
.BR mq_receive (3),
.BR mq_send (3),
.BR mq_unlink (3),
.BR epoll (7)
|