1 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Tue Oct 22 16:40:11 1996 by Eric S. Raymond <esr@thyrsus.com>
24 .\" Modified Mon Jul 10 21:09:59 2000 by aeb
25 .\" Modified 1 Jun 2002, Michael Kerrisk <mtk.manpages@gmail.com>
26 .\" Language clean-ups.
27 .\" Enhanced and corrected information on msg_qbytes, MSGMNB and MSGMAX
28 .\" Added note on restart behavior of msgsnd() and msgrcv()
29 .\" Formatting clean-ups (argument and field names marked as .I
31 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
32 .\" Added notes on capability requirements
33 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
34 .\" Language and formatting clean-ups
35 .\" Added notes on /proc files
36 .\" FIXME . Add example programs to this page.
38 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
39 .\" all rights reserved.
40 .\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
41 .\" Modified 2000-09-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
42 .\" Updated 2002-11-26, Kentaro Shirakata <argrath@ub32.org>
43 .\" Updated 2005-03-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2006-03-05, Akihiro MOTOKI, LDP v2.25
45 .\" Updated 2008-08-09, Akihiro MOTOKI, LDP v3.05
47 .\"WORD: message メッセージ
51 .\"WORD: catch 捕獲(catch)
53 .\"WORD: suspend 停止(suspend)
54 .\"WORD: sleep 停止(sleep)
55 .\"WORD: block 停止(block)
56 .\"WORD: process-ID プロセスID
59 .\"WORD: super-user スーパー・ユーザー
60 .\"WORD: current time 現在時刻
63 .TH MSGOP 2 2008-04-23 "Linux" "Linux Programmer's Manual"
66 .\"O msgrcv, msgsnd \- message operations
67 msgrcv, msgsnd \- メッセージ操作
71 .B #include <sys/types.h>
72 .B #include <sys/ipc.h>
73 .B #include <sys/msg.h>
75 .BI "int msgsnd(int " msqid ", const void *" msgp ", size_t " msgsz \
78 .BI "ssize_t msgrcv(int " msqid ", void *" msgp ", size_t " msgsz \
88 .\"O system calls are used, respectively, to send messages to,
89 .\"O and receive messages from, a message queue.
90 .\"O The calling process must have write permission on the message queue
91 .\"O in order to send a message, and read permission to receive a message.
96 はそれぞれ、メッセージ・キューへのメッセージの送信と、
97 メッセージの受信に使用される。呼び出し元プロセスは、
98 メッセージを送信するためにはメッセージ・キューに対する書き込み許可を、
99 メッセージを受信するためには読み出し許可を持っていなければならない。
103 .\"O argument is a pointer to caller-defined structure
104 .\"O of the following general form:
105 呼び出し元プロセスは以下に示す構造体を用意し、この構造体への
113 long mtype; /* message type, must be > 0 */
114 char mtext[1]; /* message data */
121 .\"O field is an array (or other structure) whose size is specified by
123 .\"O a nonnegative integer value.
125 フィールドは配列 (または他の構造体) で、その大きさは
129 .\"O Messages of zero length (i.e., no
131 .\"O field) are permitted.
134 フィールドがないメッセージ) も認められている。
137 .\"O field must have a strictly positive integer value.
138 .\"O This value can be
139 .\"O used by the receiving process for message selection
140 .\"O (see the description of
144 フィールドは厳密に正の整数でなければならない。
145 この値は、メッセージを受信するプロセスでメッセージを選択するために
152 .\"O system call appends a copy of the message pointed to by
154 .\"O to the message queue whose identifier is specified
162 で指定された識別子を持つメッセージ・キューへ追加する。
164 .\"O If sufficient space is available in the queue,
166 .\"O succeeds immediately.
170 .\"O (The queue capacity is defined by the
172 .\"O field in the associated data structure for the message queue.
173 .\"O During queue creation this field is initialized to
175 .\"O bytes, but this limit can be modified using
176 .\"O .BR msgctl (2).)
177 (キューの容量は、メッセージ・キューのデータ構造体の
185 .\"O If insufficient space is available in the queue, then the default
188 .\"O is to block until space becomes available.
192 は空き容量ができるまで停止 (block) する。
197 .\"O then the call instead fails with the error
208 .\"O call may also fail if:
213 .\"O the queue is removed,
214 .\"O in which case the system call fails with
226 .\"O a signal is caught, in which case the system call fails
241 .\"O is never automatically restarted after being interrupted by a
242 .\"O signal handler, regardless of the setting of the
244 .\"O flag when establishing a signal handler.)
248 を指定していたとしても、シグナルハンドラによって割り込まれた後で
249 自動的に再スタートすることは決してない。)
251 .\"O Upon successful completion the message queue data structure is updated
253 正常に終了した場合、メッセージ・キューのデータ構造体は以下のように
257 .\"O is set to the process ID of the calling process.
259 には呼び出し元プロセスのプロセス ID が設定される。
262 .\"O is incremented by 1.
267 .\"O is set to the current time.
273 .\"O system call removes a message from the queue specified by
275 .\"O and places it in the buffer
281 で指定されたキューからメッセージを削除し、
283 で指定されたバッファにそのメッセージを格納する。
287 .\"O specifies the maximum size in bytes for the member
289 .\"O of the structure pointed to by the
298 .\"O If the message text has length greater than
300 .\"O then the behavior depends on whether
306 .\"O is specified, then
307 .\"O the message text will be truncated (and the truncated part will be
310 .\"O is not specified, then
311 .\"O the message isn't removed from the queue and
312 .\"O the system call fails returning \-1 with
324 が指定されていれば、メッセージのテキストは切り詰められる
327 が指定されていなければ、メッセージはキューから削除されず、
328 システムコールは \-1 を返して失敗し、
336 .\"O specifies the type of message requested as follows:
338 引き数には要求するメッセージの型を指定する。
344 .\"O then the first message in the queue is read.
346 が 0 ならば、キューの最初にあるメッセージが読み込まれる。
350 .\"O is greater than 0,
351 .\"O then the first message in the queue of type
355 .\"O was specified in
358 .\"O the first message in the queue of type not equal to
368 型のキューの最初のメッセージが読み込まれる。
372 型以外のキューの最初のメッセージが読み込まれる。
377 .\"O then the first message in the queue with the lowest type less than or
378 .\"O equal to the absolute value of
384 の絶対値以下で最も小さい型を持つキューの最初のメッセージが読み込まれる。
388 .\"O argument is a bit mask constructed by ORing together zero or more
389 .\"O of the following flags:
391 引き数には、以下のフラグを任意の数だけ (0個も可)、これらの OR で指定する:
394 .\"O Return immediately if no message of the requested type is in the queue.
395 .\"O The system call fails with
399 キューに要求された型のメッセージがない場合には直ちに返る。
410 .\"O to read the first message in the queue with message type that differs
417 以外のキューの最初のメッセージを読み込む。
420 .\"O To truncate the message text if longer than
424 バイトよりも長かった場合はメッセージのテキストを切り詰める。
426 .\"O If no message of the requested type is available and
428 .\"O isn't specified in
430 .\"O the calling process is blocked until one of the following conditions occurs:
435 が指定されていなかった場合、呼び出し元プロセスは
436 以下のいずれかの状況になるまで停止 (block) される:
438 .\"O A message of the desired type is placed in the queue.
439 要求している型のメッセージがキューへ入れられた。
441 .\"O The message queue is removed from the system.
442 .\"O In this case the system call fails with
446 メッセージ・キューがシステムから削除された。
453 .\"O The calling process catches a signal.
454 .\"O In this case the system call fails with
465 .\"O is never automatically restarted after being interrupted by a
466 .\"O signal handler, regardless of the setting of the
468 .\"O flag when establishing a signal handler.)
472 を指定していたとしても、シグナルハンドラによって割り込まれた後で
473 自動的に再スタートすることは決してない。)
475 .\"O Upon successful completion the message queue data structure is updated
477 実行に成功した場合、メッセージ・キューのデータ構造体は以下のように
481 .\"O is set to the process ID of the calling process.
483 には呼び出し元プロセスのプロセス ID が設定される。
486 .\"O is decremented by 1.
491 .\"O is set to the current time.
494 .\"O .SH "RETURN VALUE"
496 .\"O On failure both functions return \-1
499 .\"O indicating the error,
505 .\"O returns the number of bytes actually copied into the
508 失敗した場合は、どちらの関数も \-1 を返し、エラーを
523 .\"O will be set to one among the following values:
530 .\"O The calling process does not have write permission on the message queue,
531 .\"O and does not have the
532 .\"O .B CAP_IPC_OWNER
534 呼び出し元プロセスにはメッセージ・キューに対する書き込み許可がなく、
539 .\"O The message can't be sent due to the
541 .\"O limit for the queue and
543 .\"O was specified in
546 がキューの制限を超えていたため、メッセージを送ることができず、かつ
553 .\"O The address pointed to by
555 .\"O isn't accessible.
557 が指しているアドレスがアクセス可能でない。
560 .\"O The message queue was removed.
564 .\"O Sleeping on a full message queue condition, the process caught a signal.
565 メッセージ・キューが要求した条件を満たすまで停止している時に、
571 .\"O value, or nonpositive
576 .\"O value (less than 0 or greater than the system value
583 が不適切な値 (0 以下か、システムで決まる値
588 .\"O The system does not have enough memory to make a copy of the
589 .\"O message pointed to by
592 が指すメッセージのコピーを作成するのに十分なメモリがシステムに存在しない。
598 .\"O will be set to one among the following values:
605 .\"O The message text length is greater than
609 .\"O isn't specified in
620 .\"O The calling process does not have read permission on the message queue,
621 .\"O and does not have the
622 .\"O .B CAP_IPC_OWNER
624 呼び出し元プロセスにはメッセージ・キューに対する読み込み許可がなく、
629 .\"O No message was available in the queue and
631 .\"O was specified in
640 .\"O The address pointed to by
642 .\"O isn't accessible.
644 が指しているアドレスがアクセス可能でない。
647 .\"O While the process was sleeping to receive a message,
648 .\"O the message queue was removed.
649 メッセージを受信するためにプロセスが停止している間に、
653 .\"O While the process was sleeping to receive a message,
654 .\"O the process caught a signal; see
656 メッセージを受けるためにプロセスが停止している間に、
665 .\"O was less than 0.
673 .\"O was specified in
675 .\"O and no message of the requested type existed on the message queue.
680 メッセージ・キューに要求された型のメッセージが存在しなかった。
681 .\"O .SH "CONFORMING TO"
688 .\"O argument is declared as \fIstruct msgbuf *\fP with
689 .\"O libc4, libc5, glibc 2.0, glibc 2.1.
690 .\"O It is declared as \fIvoid *\fP
691 .\"O with glibc 2.2 and later, as required by SUSv2 and SUSv3.
693 引き数は、 libc4, libc5, glibc 2.0, glibc 2.1 では
694 \fIstruct msgbuf *\fP と宣言されている。glibc 2.2 以降では、
695 SUSv2 と SUSv3 の要求通り、\fIvoid *\fP と宣言されている。
697 .\"O The following limits on message queue resources affect the
702 システムコールに影響するシステム制限である:
705 .\"O Maximum size for a message text: 8192 bytes
706 .\"O (on Linux, this limit can be read and modified via
707 .\"O .IR /proc/sys/kernel/msgmax ).
708 メッセージのテキストの最大サイズ: 8192 バイト
710 .I /proc/sys/kernel/msgmax
714 .\"O Default maximum size in bytes of a message queue: 16384 bytes
715 .\"O (on Linux, this limit can be read and modified via
716 .\"O .IR /proc/sys/kernel/msgmnb ).
717 .\"O The superuser can increase the size of a message queue beyond
722 バイト単位でのメッセージ・キューのデフォルトの最大サイズ : 16384 バイト。
724 .I /proc/sys/kernel/msgmnb
728 システムコールでメッセージ・キューのサイズを
732 .\"O The implementation has no intrinsic limits for the system wide maximum
733 .\"O number of message headers
735 .\"O and for the system wide maximum size in bytes of the message pool
736 .\"O .RB ( MSGPOOL ).
737 現在の実装では、システム全体のメッセージ・ヘッダーの最大数
739 と、システム全体のメッセージ・プールの最大バイト数
746 .BR capabilities (7),