'\" t .\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (C) 2006 Michael Kerrisk .\" .\" 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-04-23, Akihiro MOTOKI .\" .TH MQ_OPEN 3 2009-02-20 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O mq_open \- open a message queue mq_open \- メッセージキューをオープンする .\"O .SH SYNOPSIS .SH 書式 .nf .BR "#include " " /* For O_* constants */" .BR "#include " " /* For mode constants */" .B #include .sp .BI "mqd_t mq_open(const char *" name ", int " oflag ); .BI "mqd_t mq_open(const char *" name ", int " oflag ", mode_t " mode , .BI " struct mq_attr *" attr ); .fi .sp .\"O Link with \fI\-lrt\fP. \fI\-lrt\fP でリンクする。 .\"O .SH DESCRIPTION .SH 説明 .\"O .BR mq_open () .\"O creates a new POSIX message queue or opens an existing queue. .\"O The queue is identified by .\"O .IR name . .\"O For details of the construction of .\"O .IR name , .\"O see .\"O .BR mq_overview (7). .BR mq_open () は、新しい POSIX メッセージキューを作成するか、既存のキューを オープンする。キューは .I name で識別される。 .I name の構成の詳細については .B mq_overview (7) を参照。 .\"O The .\"O .I oflag .\"O argument specifies flags that control the operation of the call. .\"O (Definitions of the flags values can be obtained by including .\"O .IR .) .\"O Exactly one of the following must be specified in .\"O .IR oflag : .I oflag 引き数には、関数呼び出しの操作を制御するフラグを指定する (oflag の値の定義は .I のインクルードにより得られる)。 .I oflag には、以下のうちいずれか一つを必ず指定しなければならない。 .TP .B O_RDONLY .\"O Open the queue to receive messages only. メッセージの受信専用としてキューをオープンする。 .TP .B O_WRONLY .\"O Open the queue to send messages only. メッセージの送信専用としてキューをオープンする。 .TP .B O_RDWR .\"O Open the queue to both send and receive messages. メッセージの送受信両用としてキューをオープンする。 .PP .\"O Zero or more of the following flags can additionally be .\"O .IR OR ed .\"O in .\"O .IR oflag : 0 個以上の下記のフラグを、ビット単位の OR (論理和) で .I oflag に追加で指定できる。 .TP .B O_NONBLOCK .\"O Open the queue in nonblocking mode. .\"O In circumstances where .\"O .BR mq_receive (3) .\"O and .\"O .BR mq_send (3) .\"O would normally block, these functions instead fail with the error .\"O .BR EAGAIN . 非停止 (nonblocking) モードでキューをオープンする。 .BR mq_receive (3) と .BR mq_send (3) は、通常は停止 (block) する状況において、エラー .B EAGAIN で失敗するようになる。 .TP .B O_CREAT .\"O Create the message queue if it does not exist. .\"O The owner (user ID) of the message queue is set to the effective .\"O user ID of the calling process. .\"O The group ownership (group ID) is set to the effective group ID .\"O of the calling process. .\"O .\" In reality the file system IDs are used on Linux. 存在しない場合、メッセージキューを作成する。 メッセージキューの所有者 (ユーザ ID) とグループ所有権 (グループ ID) は、 それぞれ呼び出し元プロセスの実効ユーザ ID と実効グループ ID に設定される。 .\" 実際は、Linux ではファイルシステム ID が使用される。 .TP .B O_EXCL .\"O If .\"O .B O_CREAT .\"O was specified in .\"O .IR oflag , .\"O and a queue with the given .\"O .I name .\"O already exists, then fail with the error .\"O .BR EEXIST . .B O_CREAT が .I oflag に指定され、かつ指定された名前 .I name を持つキューがすでに存在する場合、エラー .B EEXIST で失敗する。 .PP .\"O If .\"O .B O_CREAT .\"O is specified in .\"O .IR oflag , .\"O then two additional arguments must be supplied. .I oflag に .B O_CREAT を指定する場合、追加で 2つの引き数を与える必要がある。 .\"O The .\"O .I mode .\"O argument specifies the permissions to be placed on the new queue, .\"O as for .\"O .BR open (2). .\"O (Symbolic definitions for the permissions bits can be obtained by including .\"O .IR .) .\"O The permissions settings are masked against the process umask. .I mode 引き数は、新しいキューに適用される許可設定 (permission) を、 .BR open (2) と同じように指定する (許可ビットのシンボル定義は .I のインクルードにより得られる)。 許可設定はプロセスの umask でマスクされる。 .\"O The .\"O .I attr .\"O argument specifies attributes for the queue. .\"O See .\"O .BR mq_getattr (3) .\"O for details. .\"O If .\"O .I attr .\"O is NULL, then the queue is created with implementation-defined .\"O default attributes. .I attr 引き数は、キューの属性を指定する。詳細は、 .BR mq_getattr (3) を参照。 .I attr が NULL の場合、キューは実装で定義されたデフォルト属性で作成される。 .\"O .SH RETURN VALUE .SH 返り値 .\"O On success, .\"O .BR mq_open () .\"O returns a message queue descriptor for use by other .\"O message queue functions. 成功すると、 .BR mq_open () はメッセージキュー記述子 (message queue descriptor) を返す。 メッセージキュー記述子は他のメッセージキュー関連の関数で使用される。 .\"O On error, .\"O .BR mq_open () .\"O returns .\"O .IR "(mqd_t)\ \-1", .\"O with .\"O .I errno .\"O set to indicate the error. エラーの場合、 .BR mq_open () は .I "(mqd_t)\ \-1" を返し、 .I errno にエラーを示す値を設定する。 .\"O .SH ERRORS .SH エラー .TP .B EACCES .\"O The queue exists, but the caller does not have permission to .\"O open it in the specified mode. キューは存在するが、呼び出し元が指定されたモードでそのキュー をオープンする許可を持たない。 .TP .B EACCES .\"O .I name .\"O contained more than one slash. .I name にスラッシュが 2 個以上含まれていた。 .\" Note that this isn't consistent with the same case for sem_open() .TP .B EEXIST .\"O Both .\"O .B O_CREAT .\"O and .\"O .B O_EXCL .\"O were specified in .\"O .IR oflag , .\"O but a queue with this .\"O .I name .\"O already exists. .I oflag に .B O_CREAT と .B O_EXCL の両方が指定されたが、指定された名前 .I name を持つキューがすでに存在する。 .TP .B EINVAL .\"O .B O_CREAT .\"O was specified in .\"O .IR oflag , .\"O and .\"O .I attr .\"O was not NULL, but .\"O .I attr\->mq_maxmsg .\"O or .\"O .I attr\->mq_msqsize .\"O was invalid. .\"O Both of these fields must be greater than zero. .I oflag に .B O_CREAT が指定され、かつ .I attr が NULL 以外だが、 .I attr\->mq_maxmsg か .I attr\->mq_msqsize が不正であった。 これらのフィールドは両方とも 0 より大きくなければならない。 .\"O In a process that is unprivileged (does not have the .\"O .B CAP_SYS_RESOURCE .\"O capability), .\"O .I attr\->mq_maxmsg .\"O must be less than or equal to the .\"O .I msg_max .\"O limit, and .\"O .I attr\->mq_msgsize .\"O must be less than or equal to the .\"O .I msgsize_max .\"O limit. .\"O In addition, even in a privileged process, .\"O .I attr\->mq_maxmsg .\"O cannot exceed the .\"O .B HARD_MAX .\"O limit. .\"O (See .\"O .BR mq_overview (7) .\"O for details of these limits.) プロセスが特権を持たない .RB ( CAP_SYS_RESOURCE ケーパビリティを持たない) 場合、 .I attr\->mq_maxmsg と .I attr\->mq_msgsize は、それぞれ上限 .IR msg_max 、 .I msgsize_max 以下でなければならない。 また、特権プロセスの場合でも、 .I attr\->mq_maxmsg は .B HARD_MAX 上限を超えることはできない。 (これらの上限に関する詳細は .BR mq_overview (7) を参照。) .TP .B EMFILE .\"O The process already has the maximum number of files and .\"O message queues open. そのプロセスがオープンしているファイルとメッセージキューの数が プロセス毎の上限に達している。 .TP .B ENAMETOOLONG .\"O .I name .\"O was too long. .I name が長すぎる。 .TP .B ENFILE .\"O The system limit on the total number of open files and message queues .\"O has been reached. システム全体でオープンしているファイルとメッセージキューの合計数が システム上限に達している。 .TP .B ENOENT .\"O The .\"O .B O_CREAT .\"O flag was not specified in .\"O .IR oflag , .\"O and no queue with this .\"O .I name .\"O exists. .B O_CREAT フラグが .I oflag に指定されなかったが、指定された名前 .I name を持つキューが存在しない。 .TP .B ENOENT .\"O .I name .\"O was just "/" followed by no other characters. .I name が "/" だけで、その後ろに他の文字が続いていなかった。 .\" Note that this isn't consistent with the same case for sem_open() .TP .B ENOMEM .\"O Insufficient memory. 十分なメモリがない。 .TP .B ENOSPC .\"O Insufficient space for the creation of a new message queue. .\"O This probably occurred because the .\"O .I queues_max .\"O limit was encountered; see .\"O .BR mq_overview (7). 新しいメッセージキューを作成するのに十分な空間がない。 このエラーはおそらく .I queues_max 上限に抵触したため起こったのだろう。 .BR mq_overview (7) を参照。 .\"O .SH CONFORMING TO .SH 準拠 POSIX.1-2001. .\"O .SH BUGS .SH バグ .\"O In kernels before 2.6.14, .\"O the process umask was not applied to the permissions specified in .\"O .IR mode . 2.6.14 より前のカーネルには、 プロセスの umask が .I mode で指定された許可設定に適用されなかった。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR mq_close (3), .BR mq_getattr (3), .BR mq_notify (3), .BR mq_receive (3), .BR mq_send (3), .BR mq_unlink (3), .BR mq_overview (7)