.\" t .\" Copyright (C) 2006 Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved. .\" Translated 2006-04-18, Akihiro MOTOKI .\" Updated 2009-02-23, Akihiro MOTOKI , LDP v3.19 .\" .TH SEM_OPEN 3 2012\-05\-13 Linux "Linux Programmer's Manual" .SH 名前 sem_open \- 名前付きセマフォを初期化し、オープンする .SH 書式 .nf \fB#include \fP /* For O_* constants */ \fB#include \fP /* For mode constants */ \fB#include \fP .sp \fBsem_t *sem_open(const char *\fP\fIname\fP\fB, int \fP\fIoflag\fP\fB);\fP \fBsem_t *sem_open(const char *\fP\fIname\fP\fB, int \fP\fIoflag\fP\fB, \fP \fB mode_t \fP\fImode\fP\fB, unsigned int \fP\fIvalue\fP\fB);\fP .fi .sp \fI\-pthread\fP とリンクする。 .SH 説明 \fBsem_open\fP() は、新規の POSIX セマフォを作成するか、既存のセマフォのオープンを行う。 セマフォは \fIname\fP で識別される。 \fIname\fP の構成の詳細は \fBsem_overview\fP(7) を参照。 .\" In reality the filesystem IDs are used on Linux. \fIoflag\fP 引き数には、 \fBsem_open\fP() の動作を制御するフラグを指定する (oflag の値の定義は \fI\fP のインクルードにより得られる)。 \fIoflag\fP に \fBO_CREAT\fP が指定されると、まだ存在しない場合にはそのセマフォが作成される。 セマフォの所有者 (ユーザー ID)、グループ所有権 (グループ ID) には、 それぞれ呼び出し元プロセスの実効 UID、実効 GID が設定される。 \fIoflag\fP に \fBO_CREAT\fP と \fBO_EXCL\fP の両方が指定された場合、指定された名前 \fIname\fP のセマフォがすでに存在するとエラーが返される。 .PP \fIoflag\fP に \fBO_CREAT\fP を指定する場合、さらに引き数が 2 つ必要である。 \fImode\fP 引き数は、 \fBopen\fP(2) と同じように、新しいセマフォに設定されるアクセス許可 (permission) を 指定する。許可設定はプロセスの umask でマスクされる (許可ビットのシンボル定義は \fI\fP のインクルードにより得られる)。 セマフォにアクセスしようとするユーザーは、読み出し許可と書き込み許可の 両方を得る必要がある。 \fIvalue\fP 引き数は新しいセマフォの初期値を指定する。 \fBO_CREAT\fP が指定され、指定した名前 \fIname\fP のセマフォがすでに存在する場合、 \fImode\fP と \fIvalue\fP は無視される。 .SH 返り値 成功すると、 \fBsem_open\fP() は新しいセマフォのアドレスを返す。 このアドレスは他のセマフォ関連の関数を呼び出す際に使用される。 エラーの場合、 \fBsem_open\fP() は \fBSEM_FAILED\fP を返し、 \fIerrno\fP にエラーを示す値をセットする。 .SH エラー .TP \fBEACCES\fP そのセマフォが存在するが、呼び出し元にはそのセマフォをオープンする 許可がない。 .TP \fBEEXIST\fP \fIoflag\fP に \fBO_CREAT\fP と \fBO_EXCL\fP の両方が指定されたが、 \fIname\fP という名前のセマフォはすでに存在する。 .TP \fBEINVAL\fP \fIvalue\fP が \fBSEM_VALUE_MAX\fP よりも大きい。 .TP \fBEINVAL\fP \fIname\fP が "/" だけで構成され、その後ろに他の文字が続いていなかった。 .TP \fBEMFILE\fP オープンされたファイル数がすでにそのプロセスにおける上限に達している。 .TP \fBENAMETOOLONG\fP \fIname\fP が長すぎる。 .TP \fBENFILE\fP オープンされたファイル総数がシステム全体での上限に達している。 .TP \fBENOENT\fP .\" this error can occur if we have a name of the (nonportable) form .\" /dir/name, and the directory /dev/shm/dir does not exist. \fIoflag\fP に \fBO_CREAT\fP フラグが指定されておらず、 \fIname\fP という名前のセマフォも存在しない。 または、 \fBO_CREAT\fP が指定されたが、 \fIname\fP が適切な形式ではなかった。 .TP \fBENOMEM\fP 十分なメモリーがない。 .SH 準拠 POSIX.1\-2001. .SH 関連項目 \fBsem_close\fP(3), \fBsem_getvalue\fP(3), \fBsem_post\fP(3), \fBsem_unlink\fP(3), \fBsem_wait\fP(3), \fBsem_overview\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。