OSDN Git Service

(split) LDP: draft snapshot generated from latest ja.po files.
[linuxjm/LDP_man-pages.git] / draft / man2 / write.2
index 11651ef..4e1518c 100644 (file)
 .\"    gave some examples of why this might occur.
 .\"    Noted what happens if write() is interrupted by a signal.
 .\"
-.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
-.\"         all rights reserved.
-.\" Translated Tue Mar  4 00:18:20 JST 1997
-.\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
-.\" Updated & Modified Wed Jun 13 20:57:55 JST 2001
-.\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
-.\" Updated Mon Jun 25 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
-.\" Updated Fri Dec 21 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
-.\" Updated 2002-09-24 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
-.\" Updated 2005-10-14 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
-.\" Updated 2007-05-01, Akihiro MOTOKI, LDP v2.46
-.\" Updated 2007-09-01, Akihiro MOTOKI, LDP v2.64
-.\" Updated 2008-04-13, Akihiro MOTOKI, LDP v3.20
+.\"*******************************************************************
 .\"
-.\"WORD:       descriptor              ディスクリプタ
-.\"WORD:       buffer                  バッファー
-.\"WORD:       file system             ファイル・システム
-.\"WORD:       object                  オブジェクト
-.\"WORD:       pipe                    パイプ
-.\"WORD:       socket                  ソケット
-.\"WORD:       signal                  シグナル
-.\"WORD:       catch                   捕獲(catch)
-.\"WORD:       block                   停止(block)
-.\"WORD:       interrupt               割り込み
-.\"WORD:       nonblocking I/O         非停止 I/O
-.\"WORD:       device                  デバイス
-.\"WORD:       low-level I/O           低レべル I/O
+.\" This file was generated with po4a. Translate the source file.
 .\"
-.TH WRITE 2 2010-08-29 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
+.\"*******************************************************************
+.TH WRITE 2 2010\-08\-29 Linux "Linux Programmer's Manual"
 .SH 名前
-.\"O write \- write to a file descriptor
 write \- ファイル・ディスクリプタ (file descriptor) に書き込む
-.\"O .SH SYNOPSIS
 .SH 書式
-.B #include <unistd.h>
+\fB#include <unistd.h>\fP
 .sp
-.BI "ssize_t write(int " fd ", const void *" buf ", size_t " count );
-.\"O .SH DESCRIPTION
+\fBssize_t write(int \fP\fIfd\fP\fB, const void *\fP\fIbuf\fP\fB, size_t \fP\fIcount\fP\fB);\fP
 .SH 説明
-.\"O .BR write ()
-.\"O writes up to
-.\"O .I count
-.\"O bytes from the buffer pointed
-.\"O .I buf
-.\"O to the file referred to by the file descriptor
-.\"O .IR fd .
-.BR write ()
-は、
-.I buf
-が指すバッファから、ファイル・ディスクリプタ
-.I fd
-が参照するファイルへ、最大
-.I count
+\fBwrite\fP()  は、 \fIbuf\fP が指すバッファから、ファイル・ディスクリプタ \fIfd\fP が参照するファイルへ、最大 \fIcount\fP
 バイトを書き込む。
 
-.\"O The number of bytes written may be less than
-.\"O .I count
-.\"O if, for example,
-.\"O there is insufficient space on the underlying physical medium, or the
-.\"O .B RLIMIT_FSIZE
-.\"O resource limit is encountered (see
-.\"O .BR setrlimit (2)),
-.\"O or the call was interrupted by a signal
-.\"O handler after having written less than
-.\"O .I count
-.\"O bytes.
-.\"O (See also
-.\"O .BR pipe (7).)
-書き込まれるバイト数は
-.I count
-よりも小さくなることがある。
-例えば、書き込み対象の物理メディアに十分な領域がない場合、
-リソース上限
-.B RLIMIT_FSIZE
-に達した場合
-.RB ( setrlimit (2)
-参照)、
-.I count
-バイト未満の書き込みが行われた後で
-呼び出しがシグナルハンドラにより割り込まれた場合、
-などである。
-.RB ( pipe (7)
-も参照のこと。)
+書き込まれるバイト数は \fIcount\fP よりも小さくなることがある。 例えば、書き込み対象の物理メディアに十分な領域がない場合、 リソース上限
+\fBRLIMIT_FSIZE\fP に達した場合 (\fBsetrlimit\fP(2)  参照)、 \fIcount\fP バイト未満の書き込みが行われた後で
+呼び出しがシグナルハンドラにより割り込まれた場合、 などである。 (\fBpipe\fP(7)  も参照のこと。)
 
-.\"O For a seekable file (i.e., one to which
-.\"O .BR lseek (2)
-.\"O may be applied, for example, a regular file)
-.\"O writing takes place at the current file offset,
-.\"O and the file offset is incremented by
-.\"O the number of bytes actually written.
-.\"O If the file was
-.\"O .BR open (2)ed
-.\"O with
-.\"O .BR O_APPEND ,
-.\"O the file offset is first set to the end of the file before writing.
-.\"O The adjustment of the file offset and the write operation
-.\"O are performed as an atomic step.
-seek 可能なファイル (つまり
-.BR lseek (2)
-が適用できるファイル、例えば通常のファイル) では、
-書き込みは現在のファイル・オフセットから行われ、
-ファイル・オフセットは実際に書き込みが行われたバイト数分
-加算される。ファイルが
-.B O_APPEND
-で
-.BR open (2)
-された場合、ファイル・オフセットは書き込み前に
-ファイルの末尾に設定される。
-ファイル・オフセットの調整と書き込み操作はアトミックな処理として
-実行される。
+seek 可能なファイル (つまり \fBlseek\fP(2)  が適用できるファイル、例えば通常のファイル) では、
+書き込みは現在のファイル・オフセットから行われ、 ファイル・オフセットは実際に書き込みが行われたバイト数分 加算される。ファイルが
+\fBO_APPEND\fP で \fBopen\fP(2)  された場合、ファイル・オフセットは書き込み前に ファイルの末尾に設定される。
+ファイル・オフセットの調整と書き込み操作はアトミックな処理として 実行される。
 
-.\"O POSIX requires that a
-.\"O .BR read (2)
-.\"O which can be proved to occur after a
-.\"O .BR write ()
-.\"O has returned returns the new data.
-.\"O Note that not all file systems are POSIX conforming.
-POSIX は
-.BR write ()
-が行なわれた後に実行した
-.BR read (2)
-が
-新しいデータを返すことを要求している。
+POSIX は \fBwrite\fP()  が行なわれた後に実行した \fBread\fP(2)  が 新しいデータを返すことを要求している。
 全てのファイル・システムが POSIX 準拠ではない点に注意すること。
-.\"O .SH "RETURN VALUE"
 .SH 返り値
-.\"O On success, the number of bytes written is returned (zero indicates
-.\"O nothing was written).
-.\"O On error, \-1 is returned, and \fIerrno\fP is set
-.\"O appropriately.
-成功した場合、書き込まれたバイト数が返される
-(ゼロは何も書き込まれなかったことを示す)。
-エラーならば \-1 が返され、\fIerrno\fP が適切に設定される。
+成功した場合、書き込まれたバイト数が返される (ゼロは何も書き込まれなかったことを示す)。 エラーならば \-1 が返され、\fIerrno\fP
+が適切に設定される。
 
-.\"O If \fIcount\fP is zero and
-.\"O .I fd
-.\"O refers to a regular file, then
-.\"O .BR write ()
-.\"O may return a failure status if one of the errors below is detected.
-.\"O If no errors are detected,
-.\"O 0 will be returned without causing any other effect.
-.\"O If
-.\"O \fIcount\fP is zero and
-.\"O .I fd
-.\"O refers to a file other than a regular file,
-.\"O the results are not specified.
-\fIcount\fP が 0 で、
-.I fd
-が通常のファイル (regular file) を参照している場合、
-.BR write ()
-は後述のエラーのいずれかを検出した場合、失敗を返すことがある。
-エラーが検出されなかった場合は、
-0 を返し、他に何の影響も与えない。
-\fIcount\fP が 0 で、
-.I fd
-が通常のファイル以外のファイルを参照している場合、
-その結果は規定されていない。
-.\"O .SH ERRORS
+\fIcount\fP が 0 で、 \fIfd\fP が通常のファイル (regular file) を参照している場合、 \fBwrite\fP()
+は後述のエラーのいずれかを検出した場合、失敗を返すことがある。 エラーが検出されなかった場合は、 0 を返し、他に何の影響も与えない。 \fIcount\fP
+が 0 で、 \fIfd\fP が通常のファイル以外のファイルを参照している場合、 その結果は規定されていない。
 .SH エラー
-.TP
-.B EAGAIN
-.\"O The file descriptor
-.\"O .I fd
-.\"O refers to a file other than a socket and has been marked nonblocking
-.\"O .RB ( O_NONBLOCK ),
-.\"O and the write would block.
-ファイル・ディスクリプタ
-.I fd
-がソケット以外のファイルを参照していて、
-非停止 (nonblocking) モード
-.RB ( O_NONBLOCK )
-に設定されており、書き込みを行うと停止する状況にある。
-.TP
-.\"O .BR EAGAIN " or " EWOULDBLOCK
-.BR EAGAIN " または " EWOULDBLOCK
+.TP 
+\fBEAGAIN\fP
+ファイル・ディスクリプタ \fIfd\fP がソケット以外のファイルを参照していて、 非停止 (nonblocking) モード
+(\fBO_NONBLOCK\fP)  に設定されており、書き込みを行うと停止する状況にある。
+.TP 
+\fBEAGAIN\fP または \fBEWOULDBLOCK\fP
 .\" Actually EAGAIN on Linux
-.\"O The file descriptor
-.\"O .I fd
-.\"O refers to a socket and has been marked nonblocking
-.\"O .RB ( O_NONBLOCK ),
-.\"O and the write would block.
-.\"O POSIX.1-2001 allows either error to be returned for this case,
-.\"O and does not require these constants to have the same value,
-.\"O so a portable application should check for both possibilities.
-ファイル・ディスクリプタ
-.I fd
-がソケットを参照していて、非停止 (nonblocking) モード
-.RB  ( O_NONBLOCK )
-に設定されており、書き込みを行うと停止する状況にある。
-POSIX.1-2001 は、この場合にどちらのエラーを返すことも認めており、
-これら 2 つの定数が同じ値を持つことも求めていない。
-したがって、移植性が必要なアプリケーションでは、両方の可能性を
-確認すべきである。
-.TP
-.B EBADF
-.\"O .I fd
-.\"O is not a valid file descriptor or is not open for writing.
-.I fd
-が有効なファイル・ディスクリプタでないか書き込みのためにオープン
-(open) されていない。
-.TP
-.B EDESTADDRREQ
-.\"O .I fd
-.\"O refers to a datagram socket for which a peer address has not been set using
-.\"O .BR connect (2).
-.I fd
-が、
-.BR connect (2)
-を使って通信相手のアドレスが設定されていないデータグラムソケットを
-参照している。
-.TP
-.B EFAULT
-.\"O .I buf
-.\"O is outside your accessible address space.
-.I buf
-がアクセス可能なアドレス空間 (address space) の外にある。
-.TP
-.B EFBIG
-.\"O An attempt was made to write a file that exceeds the implementation-defined
-.\"O maximum file size or the process's file size limit,
-.\"O or to write at a position past the maximum allowed offset.
-実装定義の最大ファイルサイズまたはプロセスのファイルサイズ制限を
-超えてファイルに書き込もうとした。
-または許可されたオフセット値の限界を超えた先の位置に
-書き込もうとした。
-.TP
-.B EINTR
-.\"O The call was interrupted by a signal before any data was written; see
-.\"O .BR signal (7).
-何のデータも書かない間にシグナルにより割り込まれた (interrupt)。
-.BR signal (7)
-参照。
-.TP
-.B EINVAL
-.\"O .I fd
-.\"O is attached to an object which is unsuitable for writing;
-.\"O or the file was opened with the
-.\"O .B O_DIRECT
-.\"O flag, and either the address specified in
-.\"O .IR buf ,
-.\"O the value specified in
-.\"O .IR count ,
-.\"O or the current file offset is not suitably aligned.
-.I fd
-が書き込みが不適切なオブジェクトを参照している。
-もしくは、ファイルが
-.B O_DIRECT
-フラグを指定してオープンされているが、
-.I buf
-に指定されたアドレス、
-.I count
-に指定された値、
-現在のファイルオフセットのいずれかの
-アラインメントが不適切である。
-.TP
-.B EIO
-.\"O A low-level I/O error occurred while modifying the inode.
-inode の修正中に低レべル (low-level) I/O エラーが発生した。
-.TP
-.B ENOSPC
-.\"O The device containing the file referred to by
-.\"O .I fd
-.\"O has no room for the data.
-.I fd
-によって参照されるファイルを含むデバイス (device) に十分な空きがない。
-.TP
-.B EPIPE
-.\"O .I fd
-.\"O is connected to a pipe or socket whose reading end is closed.
-.\"O When this happens the writing process will also receive a
-.\"O .B SIGPIPE
-.\"O signal.
-.\"O (Thus, the write return value is seen only if the program
-.\"O catches, blocks or ignores this signal.)
-.I fd
-がパイプ (pipe) かソケット (socket) に接続されており、
-その反対側 (読み込み側) がクローズ (close) されている。
-これが発生した場合には、書き込みを行なうプロセスは
-.B SIGPIPE
-シグナル (signal)も受ける。
-(したがって、プログラムがこのシグナルを捕獲 (catch)、停止 (block)、無視 (ignore)
-した場合のみ、write の返り値を参照できる。)
+ファイル・ディスクリプタ \fIfd\fP がソケットを参照していて、非停止 (nonblocking) モード (\fBO_NONBLOCK\fP)
+に設定されており、書き込みを行うと停止する状況にある。 POSIX.1\-2001 は、この場合にどちらのエラーを返すことも認めており、 これら 2
+つの定数が同じ値を持つことも求めていない。 したがって、移植性が必要なアプリケーションでは、両方の可能性を 確認すべきである。
+.TP 
+\fBEBADF\fP
+\fIfd\fP が有効なファイル・ディスクリプタでないか書き込みのためにオープン (open) されていない。
+.TP 
+\fBEDESTADDRREQ\fP
+\fIfd\fP が、 \fBconnect\fP(2)  を使って通信相手のアドレスが設定されていないデータグラムソケットを 参照している。
+.TP 
+\fBEFAULT\fP
+\fIbuf\fP がアクセス可能なアドレス空間の外にある。
+.TP 
+\fBEFBIG\fP
+実装定義の最大ファイルサイズまたはプロセスのファイルサイズ制限を 超えてファイルに書き込もうとした。
+または許可されたオフセット値の限界を超えた先の位置に 書き込もうとした。
+.TP 
+\fBEINTR\fP
+何のデータも書かない間にシグナルにより割り込まれた (interrupt)。 \fBsignal\fP(7)  参照。
+.TP 
+\fBEINVAL\fP
+\fIfd\fP が書き込みが不適切なオブジェクトを参照している。 もしくは、ファイルが \fBO_DIRECT\fP フラグを指定してオープンされているが、
+\fIbuf\fP に指定されたアドレス、 \fIcount\fP に指定された値、 現在のファイルオフセットのいずれかの アラインメントが不適切である。
+.TP 
+\fBEIO\fP
+inode の修正中に低レべル (low\-level) I/O エラーが発生した。
+.TP 
+\fBENOSPC\fP
+\fIfd\fP によって参照されるファイルを含むデバイス (device) に十分な空きがない。
+.TP 
+\fBEPIPE\fP
+\fIfd\fP がパイプ (pipe) かソケット (socket) に接続されており、 その反対側 (読み込み側) がクローズ (close)
+されている。 これが発生した場合には、書き込みを行なうプロセスは \fBSIGPIPE\fP シグナル (signal)も受ける。
+(したがって、プログラムがこのシグナルを捕獲 (catch)、停止 (block)、無視 (ignore)  した場合のみ、write
+の返り値を参照できる。)
 .PP
-.\"O Other errors may occur, depending on the object connected to
-.\"O .IR fd .
-.I fd
-に接続されたオブジェクトによっては、他のエラーが起こるかもしれない。
-.\"O .SH "CONFORMING TO"
+\fIfd\fP に接続されたオブジェクトによっては、他のエラーが起こるかもしれない。
 .SH 準拠
-SVr4, 4.3BSD, POSIX.1-2001.
-.\"O .\" SVr4 documents additional error
-.\"O .\" conditions EDEADLK, ENOLCK, ENOLNK, ENOSR, ENXIO, or ERANGE.
-.\" SVr4 には他に EDEADLK, ENOLCK, ENOLNK,
-.\" ENOSR, ENXIO, ERANGE エラーについての記述がある。
+.\" SVr4 documents additional error
+.\" conditions EDEADLK, ENOLCK, ENOLNK, ENOSR, ENXIO, or ERANGE.
+SVr4, 4.3BSD, POSIX.1\-2001.
 
-.\"O Under SVr4 a write may be interrupted and return
-.\"O .B EINTR
-.\"O at any point,
-.\"O not just before any data is written.
-SVr4 では write が割り込まれると、データが書き込まれる直前ではなく、
-その時点で
-.B EINTR
-が返る。
-.\"O .SH NOTES
+SVr4 では write が割り込まれると、データが書き込まれる直前ではなく、 その時点で \fBEINTR\fP が返る。
 .SH 注意
-.\"O A successful return from
-.\"O .BR write ()
-.\"O does not make any guarantee that data has been committed to disk.
-.BR write ()
-が成功して返ってきても、データがディスクに記録されたことを
-保証するものではない。
-.\"O In fact, on some buggy implementations, it does not even guarantee
-.\"O that space has successfully been reserved for the data.
-実際、データのためのスペースが確保されたことすら保証されないという
-バグっぽい実装もある。
-.\"O The only way to be sure is to call
-.\"O .BR fsync (2)
-.\"O after you are done writing all your data.
-これを確実にする唯一の方法は、
-全てのデータを write した後に
-.BR fsync (2)
-を呼び出すことである。
+\fBwrite\fP()  が成功して返ってきても、データがディスクに記録されたことを 保証するものではない。
+実際、データのためのスペースが確保されたことすら保証されないという バグっぽい実装もある。 これを確実にする唯一の方法は、 全てのデータを write
+した後に \fBfsync\fP(2)  を呼び出すことである。
 
-.\"O If a
-.\"O .BR write ()
-.\"O is interrupted by a signal handler before any bytes are written,
-.\"O then the call fails with the error
-.\"O .BR EINTR ;
-.\"O if it is interrupted after at least one byte has been written,
-.\"O the call succeeds, and returns the number of bytes written.
-.BR write ()
-が 1 バイトも書き込まないうちにシグナルハンドラにより割り込まれた場合、
-.BR write ()
-はエラー
-.B EINTR
-で失敗する。
-1バイトでも書き込んだ後で割り込まれた場合には、
-.BR write ()
-は成功し、書き込んだバイト数を返す。
-.\"O .SH "SEE ALSO"
+\fBwrite\fP()  が 1 バイトも書き込まないうちにシグナルハンドラにより割り込まれた場合、 \fBwrite\fP()  はエラー \fBEINTR\fP
+で失敗する。 1バイトでも書き込んだ後で割り込まれた場合には、 \fBwrite\fP()  は成功し、書き込んだバイト数を返す。
 .SH 関連項目
-.BR close (2),
-.BR fcntl (2),
-.BR fsync (2),
-.BR ioctl (2),
-.BR lseek (2),
-.BR open (2),
-.BR pwrite (2),
-.BR read (2),
-.BR select (2),
-.BR writev (2),
-.BR fwrite (3)
+\fBclose\fP(2), \fBfcntl\fP(2), \fBfsync\fP(2), \fBioctl\fP(2), \fBlseek\fP(2), \fBopen\fP(2),
+\fBpwrite\fP(2), \fBread\fP(2), \fBselect\fP(2), \fBwritev\fP(2), \fBfwrite\fP(3)