Unix-system-calls-msgctl
[top]#
[[File:]]
[[File:]] |
|Web |This Site
- 初心者向けのUnix *
- Unix-ホーム
- Unix-はじめに
- Unix-ファイル管理
- Unix-ディレクトリ
- Unix-ファイル権限
- Unix-環境
- Unix-基本ユーティリティ
- Unix-パイプとフィルタ
- Unix-プロセス
- Unix-コミュニケーション
- Unix-The Vi Editor
- Unix Shellプログラミング*
- Unix-シェルとは?
- Unix-変数の使用
- Unix-特殊変数
- Unix-配列の使用
- Unix-基本的な演算子
- Unix-意思決定
- Unix-シェルループ
- Unix-ループ制御
- Unix-シェル置換
- Unix-引用メカニズム
- Unix-IOリダイレクト
- UNIX-シェル関数
- Unix-マンページヘルプ
- 高度なUnix *
- Unix-正規表現
- Unix-ファイルシステムの基本
- Unix-ユーザー管理
- Unix-システムパフォーマンス
- Unix-システムログ
- Unix-信号とトラップ
- Unixの便利なリファレンス*
- Unix-便利なコマンド
- Unix-クイックガイド
- Unix-組み込み関数
- Unix-システムコール
- Unix-コマンドリスト
- Unixの役立つリソース*
- Unix役立つリソース
選択した読書
Copyright©2014 by finddevguides
Home | References | Discussion Forums | About TP |
msgctl()-Unix、Linuxシステムコール
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] image:http://www.finddevguides.com/add- this.gif [AddThisソーシャルブックマークボタン]
広告
NAME
msgctl-メッセージ制御操作
概要
#include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> |
説明
_msqid_ds_データ構造は、次のように<sys/msg.h>で定義されています。
struct msqid_ds { struct ipc_perm msg_perm; /* Ownership and permissions time_t msg_stime; /*Time of last msgsnd()*/ time_t msg_rtime; /*Time of last msgrcv()*/ time_t msg_ctime; /*Time of last change*/ unsigned long __msg_cbytes;/*Current number of bytes in queue (non-standard)*/ msgqnum_t msg_qnum; /*Current number of messages in queue*/ msglen_t msg_qbytes; /*Maximum number of bytes allowed in queue*/ pid_t msg_lspid; /*PID of last msgsnd()*/ pid_t msg_lrpid; /*PID of last msgrcv()*/ }; |
_ipc_perm_構造は、次のように<sys/ipc.h>で定義されています(強調表示されたフィールドは、 IPC_SET を使用して設定可能です)。
struct ipc_perm { key_t key; /*Key supplied to msgget()*/ uid_t uid; /*Effective UID of owner*/ gid_t gid; /*Effective GID of owner*/ uid_t cuid; /*Effective UID of creator*/ gid_t cgid; /*Effective GID of creator*/ unsigned short mode; /*Permissions*/ unsigned short seq; /*Sequence number*/ }; |
_cmd_の有効な値は次のとおりです。
Tag
説明
_msqid_に関連付けられているカーネルデータ構造から、_buf_が指す_msqid_ds_構造に情報をコピーします。 呼び出し元には、メッセージキューの読み取りアクセス許可が必要です。
buf_が指す_msqid_ds_構造体の一部のメンバーの値を、このメッセージキューに関連付けられたカーネルデータ構造体に書き込み、その_msg_ctime_メンバーも更新します。 構造体の次のメンバーが更新されます:_msg_qbytes _、 msg_perm.uid 、 msg_perm.gid_、および(の最下位9ビット)msg_perm.mode。 呼び出しプロセスの実効UIDは、メッセージキューの所有者(msg_perm.uid)または作成者(msg_perm.cuid)と一致する必要があります。または、呼び出し元に特権が必要です。 システムパラメータ MSGMNB を超えて_msg_qbytes_値を上げるには、適切な特権(Linux: CAP_IPC_RESOURCE 機能)が必要です。
メッセージキューをすぐに削除し、すべての待機中のリーダーおよびライタープロセスを呼び起こします(エラーが返され、_errno_が EIDRM に設定されます)。 呼び出しプロセスには適切な特権が必要です。または、その有効なユーザーIDはメッセージキューの作成者または所有者のいずれかでなければなりません。
buf_が指す構造内のシステム全体のメッセージキュー制限とパラメーターに関する情報を返します。 この構造は_msginfo_型であり(したがって、キャストが必要です)、 GNU_SOURCE機能テストマクロが定義されている場合は_ <sys/msg.h> _で定義されます。
struct msginfo { int msgpool;/*Size in bytes of buffer pool used to hold message data; unused*/ int msgmap; /*Max. # of entries in message map; unused*/ int msgmax; /*Max. # of bytes that can be written in a single message*/ int msgmnb; /*Max. # of bytes that can be written to queue; used to initialize msg_qbytes during queue creation (msgget())*/ int msgmni; /*Max. # of message queues*/ int msgssz; /*Message segment size; unused*/ int msgtql; /*Max. # of messages on all queues in system; unused*/ unsigned short int msgseg; /*Max. # of segments; unused*/ }; |
msgmni _、 msgmax_、および_msgmnb_の設定は、同じ名前の_/proc_ファイルを介して変更できます。詳細については、 proc (5)を参照してください。
返り値
成功すると、 IPC_STAT 、 IPC_SET 、および IPC_RMID は0を返します。 IPC_INFO または MSG_INFO 操作が成功すると、すべてのメッセージキューに関する情報を記録しているカーネルの内部配列で最も使用されているエントリのインデックスが返されます。 (この情報は、繰り返しの MSG_STAT 操作で使用して、システム上のすべてのキューに関する情報を取得できます。) MSG_STAT 操作が成功すると、_msqid_でインデックスが指定されたキューの識別子が返されます。
エラー時には、エラーを示す_errno_とともに-1が返されます。
エラー
失敗すると、_errno_は次のいずれかに設定されます。
Tag | Description |
---|---|
*EACCES * | The argument cmd is equal to* IPC_STAT or MSG_STAT*, but the calling process does not have read permission on the message queue msqid, and does not have the CAP_IPC_OWNER capability. |
*EFAULT * | The argument cmd has the value* IPC_SET or IPC_STAT*, but the address pointed to by buf isn’t accessible. |
EIDRM | The message queue was removed. |
*EINVAL * | Invalid value for cmd or msqid. Or: for a* MSG_STAT* operation, the index value specified in msqid referred to an array slot that is currently unused. |
*EPERM * | The argument cmd has the value* IPC_SET or IPC_RMID*, but the effective user ID of the calling process is not the creator (as found in msg_perm.cuid) or the owner (as found in msg_perm.uid) of the message queue, and the process is not privileged (Linux: it does not have the CAP_SYS_ADMIN capability). |
ノート
_struct msqid_ds_のさまざまなフィールドは、Linux 2.2ではショートでしたが、Linux 2.4ではロングになりました。 これを利用するには、glibc-2.1.91以降での再コンパイルで十分です。 (カーネルは、_cmd_のIPC_64フラグによって古い呼び出しと新しい呼び出しを区別します。)
準拠
SVr4、POSIX.1-2001。
関連項目
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] [[File:]]
広告
Advertisements |