X-Git-Url: http://git.osdn.net/view?p=linuxjm%2FLDP_man-pages.git;a=blobdiff_plain;f=draft%2Fman3%2Fstdin.3;h=d1b5eaaefff165f03078561ca390e0d4fda3bbbf;hp=ac0911be18b3d961d83d98ef0348e817d9baf40d;hb=1d98b26905be2ad5ba08a94d65f57d872bae4f85;hpb=38394e00bdc712dc8637aada383aebb3a95a9cbf diff --git a/draft/man3/stdin.3 b/draft/man3/stdin.3 index ac0911be..d1b5eaae 100644 --- a/draft/man3/stdin.3 +++ b/draft/man3/stdin.3 @@ -6,268 +6,63 @@ .\" .\" 2007-12-08, mtk, Converted from mdoc to man macros .\" -.\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved. -.\" Translated 1998-03-22, NAKANO Takeo -.\" Updated 2005-09-04, Akihiro MOTOKI +.\"******************************************************************* .\" -.TH STDIN 3 2008-07-14 "Linux" "Linux Programmer's Manual" -.\"O .SH NAME -.\"O stdin, stdout, stderr \- standard I/O streams +.\" This file was generated with po4a. Translate the source file. +.\" +.\"******************************************************************* +.TH STDIN 3 2008\-07\-14 Linux "Linux Programmer's Manual" .SH 名前 stdin, stdout, stderr \- 標準入出力ストリーム -.\"O .SH SYNOPSIS .SH 書式 .nf -.B #include +\fB#include \fP -.BI "extern FILE *" stdin ; -.BI "extern FILE *" stdout ; -.BI "extern FILE *" stderr ; +\fBextern FILE *\fP\fIstdin\fP\fB;\fP +\fBextern FILE *\fP\fIstdout\fP\fB;\fP +\fBextern FILE *\fP\fIstderr\fP\fB;\fP .fi -.\"O .SH DESCRIPTION .SH 説明 -.\"O Under normal circumstances every UNIX program has three streams opened -.\"O for it when it starts up, one for input, one for output, and one for -.\"O printing diagnostic or error messages. -.\"O These are typically attached to -.\"O the user's terminal (see -.\"O .BR tty (4)) -.\"O but might instead refer to files or other devices, depending on what -.\"O the parent process chose to set up. -.\"O (See also the "Redirection" section of -.\"O .BR sh (1).) -標準の環境では、 UNIX プログラムは起動時に、オープンされているストリー -ムを 3 つ与えられる。それぞれ入力用、出力用、診断メッセージやエラーメッ -セージの表示用のものである。これらは通常ユーザの端末 -.RB ( tty (4) -を見よ) に接続されているが、親プロセスでの選択・設定によってファイル -や他のデバイスに関連づけられていることもある -.RB ( sh (1) -の「リダイレクション」セクションも参照のこと)。 -.PP -.\"O The input stream is referred to as "standard input"; the output stream is -.\"O referred to as "standard output"; and the error stream is referred to -.\"O as "standard error". -.\"O These terms are abbreviated to form the symbols -.\"O used to refer to these files, namely -.\"O .IR stdin , -.\"O .IR stdout , -.\"O and -.\"O .IR stderr . -入力ストリームは "standard input" と呼ばれる。出力ストリームは -"standard output"、エラーストリームは "standard error" と呼ばれる。 -これらの用語を短縮したものがそれぞれのファイルを示すシンボルとなる。つ -まり -.IR stdin , -.IR stdout , -.I stderr -である。 +標準の環境では、 UNIX プログラムは起動時に、オープンされているストリー ムを 3 つ与えられる。それぞれ入力用、出力用、診断メッセージやエラーメッ +セージの表示用のものである。これらは通常ユーザの端末 (\fBtty\fP(4) を見よ) に接続されているが、親プロセスでの選択・設定によってファイル +や他のデバイスに関連づけられていることもある (\fBsh\fP(1) の「リダイレクション」セクションも参照のこと)。 .PP -.\"O Each of these symbols is a -.\"O .BR stdio (3) -.\"O macro of type pointer to FILE, and can be used with functions like -.\"O .BR fprintf (3) -.\"O or -.\"O .BR fread (3). -これらのシンボルは -.BR stdio (3) -のマクロで、 FILE へのポインタ型である。したがって -.BR fprintf (3) -や -.BR fread (3) -などの関数とともに用いることができる。 +入力ストリームは "standard input" と呼ばれる。出力ストリームは "standard output"、エラーストリームは +"standard error" と呼ばれる。 これらの用語を短縮したものがそれぞれのファイルを示すシンボルとなる。つ まり \fIstdin\fP, +\fIstdout\fP, \fIstderr\fP である。 + +これらのシンボルは \fBstdio\fP(3) のマクロで、 FILE へのポインタ型である。したがって \fBfprintf\fP(3) や +\fBfread\fP(3) などの関数とともに用いることができる。 .PP -.\"O Since -.\"O .IR FILE s -.\"O are a buffering wrapper around UNIX file descriptors, the -.\"O same underlying files may also be accessed using the raw UNIX file -.\"O interface, that is, the functions like -.\"O .BR read (2) -.\"O and -.\"O .BR lseek (2). -.I FILE -は UNIX のファイルディスクリプタにバッファ機能を追加したラッパー -であるから、これらのマクロにも対応するファイルがあり、 UNIX の raw ファ -イルインタフェース -.RB ( read (2) -や -.BR lseek (2) -など) によってアクセスすることもできる。 +\fIFILE\fP は UNIX のファイルディスクリプタにバッファ機能を追加したラッパー であるから、これらのマクロにも対応するファイルがあり、 UNIX +の raw ファ イルインタフェース (\fBread\fP(2) や \fBlseek\fP(2) など) によってアクセスすることもできる。 .PP -.\"O On program startup, the integer file descriptors -.\"O associated with the streams -.\"O .IR stdin , -.\"O .IR stdout , -.\"O and -.\"O .I stderr -.\"O are 0, 1, and 2, respectively. -.\"O The preprocessor symbols -.\"O .BR STDIN_FILENO , -.\"O .BR STDOUT_FILENO , -.\"O and -.\"O .B STDERR_FILENO -.\"O are defined with these values in -.\"O \fI\fP. -.\"O (Applying -.\"O .BR freopen (3) -.\"O to one of these streams can change the file descriptor number -.\"O associated with the stream.) -プログラムの起動時には、 -ストリーム -.IR stdin , -.IR stdout , -.I stderr -に結びつけられているファイルディスクリプタの番号は、 -それぞれ 0, 1, 2 である。 -プリプロセッサシンボル -.BR STDIN_FILENO , -.BR STDOUT_FILENO , -.B STDERR_FILENO -は -.I -中でそれぞれこれらの値に定義されている。 -(これらのストリームに対して -.BR freopen (3) -を適用することで、そのストリームに関連付けられたファイルディスクリプタ -の番号を変更することができる。) +プログラムの起動時には、 ストリーム \fIstdin\fP, \fIstdout\fP, \fIstderr\fP に結びつけられているファイルディスクリプタの番号は、 +それぞれ 0, 1, 2 である。 プリプロセッサシンボル \fBSTDIN_FILENO\fP, \fBSTDOUT_FILENO\fP, +\fBSTDERR_FILENO\fP は \fI\fP 中でそれぞれこれらの値に定義されている。 (これらのストリームに対して +\fBfreopen\fP(3) を適用することで、そのストリームに関連付けられたファイルディスクリプタ の番号を変更することができる。) .PP -.\"O Note that mixing use of -.\"O .IR FILE s -.\"O and raw file descriptors can produce -.\"O unexpected results and should generally be avoided. -.\"O (For the masochistic among you: POSIX.1, section 8.2.3, describes -.\"O in detail how this interaction is supposed to work.) -.\"O A general rule is that file descriptors are handled in the kernel, -.\"O while stdio is just a library. -.\"O This means for example, that after an -.\"O .BR exec (3), -.\"O the child inherits all open file descriptors, but all old streams -.\"O have become inaccessible. -.I FILE -と raw なファイルディスクリプタの併用は、予期できない結果を生じ -ることがあるので、通常は避けるべきである。 (マゾヒスティックな人に: -POSIX.1 のセクション 8.2.3 には、この混用で動作がどのようになりそう -かが詳しく記述されている。) -一般的なルールは以下の通り: ファイルディスクリプタはカーネルによって -扱われ、 stdio は単にライブラリによって扱われるのである。すなわち例えば -.BR exec (3) -の後には、子プロセスはオープンされているファイルディスクリプタ +\fIFILE\fP と raw なファイルディスクリプタの併用は、予期できない結果を生じ ることがあるので、通常は避けるべきである。 +(マゾヒスティックな人に: POSIX.1 のセクション 8.2.3 には、この混用で動作がどのようになりそう かが詳しく記述されている。) +一般的なルールは以下の通り: ファイルディスクリプタはカーネルによって 扱われ、 stdio は単にライブラリによって扱われるのである。すなわち例えば +\fBexec\fP(3) の後には、子プロセスはオープンされているファイルディスクリプタ をすべて継承するが、親からのストリームはすべてアクセス不可となる。 .PP -.\"O Since the symbols -.\"O .IR stdin , -.\"O .IR stdout , -.\"O and -.\"O .I stderr -.\"O are specified to be macros, assigning to them is nonportable. -.\"O The standard streams can be made to refer to different files -.\"O with help of the library function -.\"O .BR freopen (3), -.\"O specially introduced to make it possible to reassign -.\"O .IR stdin , -.\"O .IR stdout , -.\"O and -.\"O .IR stderr . -.\"O The standard streams are closed by a call to -.\"O .BR exit (3) -.\"O and by normal program termination. -シンボル -.IR stdin , -.IR stdout , -.I stderr -はすべてマクロとして定義されているので、これらへの代入 -は移植性を保証されない。標準ストリームはライブラリ関数 -.BR freopen (3) -を用いれば、別のファイルを示すように変更することもできる。 -このライブラリ関数は -.IR stdin , -.IR stdout , -.I stderr -の再割り当てが可能なように特別に導入されたものである。 -標準ストリームは -.BR exit (3) -の呼び出しと、プログラムの正常終了によってクローズされる。 -.\"O .SH "CONFORMING TO" +シンボル \fIstdin\fP, \fIstdout\fP, \fIstderr\fP はすべてマクロとして定義されているので、これらへの代入 +は移植性を保証されない。標準ストリームはライブラリ関数 \fBfreopen\fP(3) を用いれば、別のファイルを示すように変更することもできる。 +このライブラリ関数は \fIstdin\fP, \fIstdout\fP, \fIstderr\fP の再割り当てが可能なように特別に導入されたものである。 +標準ストリームは \fBexit\fP(3) の呼び出しと、プログラムの正常終了によってクローズされる。 .SH 準拠 -.\"O The -.\"O .IR stdin , -.\"O .IR stdout , -.\"O and -.\"O .I stderr -.\"O macros conform to C89 -.\"O and this standard also stipulates that these three -.\"O streams shall be open at program startup. -.IR stdin , -.IR stdout , -.I stderr -マクロは C89 に準拠している。 -また C89 では、これら 3 つのストリームがプログラム -の起動時にオープンされているべきであることが規定されている。 -.\"O .SH NOTES +\fIstdin\fP, \fIstdout\fP, \fIstderr\fP マクロは C89 に準拠している。 また C89 では、これら 3 +つのストリームがプログラム の起動時にオープンされているべきであることが規定されている。 .SH 注意 -.\"O The stream -.\"O .I stderr -.\"O is unbuffered. -.\"O The stream -.\"O .I stdout -.\"O is line-buffered when it points to a terminal. -.\"O Partial lines will not -.\"O appear until -.\"O .BR fflush (3) -.\"O or -.\"O .BR exit (3) -.\"O is called, or a newline is printed. -.\"O This can produce unexpected -.\"O results, especially with debugging output. -.I stderr -ストリームはバッファリングされていない。 -.I stdout -ストリームは、端末に接続されているときには行単位でバッファリング -されている。一行に満たない内容は、 -.BR fflush (3) -か -.BR exit (3) -が呼び出されるか、改行文字が印字されるまで表示されない。これは、 -特にデバッグ時において、予期しない結果を生じる原因となるかもしれない。 -.\"O The buffering mode of the standard streams (or any other stream) -.\"O can be changed using the -.\"O .BR setbuf (3) -.\"O or -.\"O .BR setvbuf (3) -.\"O call. -標準ストリームの (あるいは他のすべてのストリームの) -バッファリングモードは、 -.BR setbuf (3) -または -.BR setvbuf (3) -を呼び出すことによって変更できる。 -.\"O Note that in case -.\"O .I stdin -.\"O is associated with a terminal, there may also be input buffering -.\"O in the terminal driver, entirely unrelated to stdio buffering. -.\"O (Indeed, normally terminal input is line buffered in the kernel.) -.\"O This kernel input handling can be modified using calls like -.\"O .BR tcsetattr (3); -.\"O see also -.\"O .BR stty (1), -.\"O and -.\"O .BR termios (3). -ただし、 -.I stdin -が端末に接続されているときは、端末のドライバでバッファリングされている -可能性がある点にも注意すること。これは stdio のバッファリングとは全く -関係なく存在しうる。 (実際、通常だと端末入力はカーネルによって行単位 -でバッファリングされている。) このカーネルによる入力の扱いは -.BR tcsetattr (3) -などの呼び出しによって変更することができる。 -.BR stty (1) -と -.BR termios (3) -も参照すること。 -.\"O .SH SEE ALSO +\fIstderr\fP ストリームはバッファリングされていない。 \fIstdout\fP ストリームは、端末に接続されているときには行単位でバッファリング +されている。一行に満たない内容は、 \fBfflush\fP(3) か \fBexit\fP(3) +が呼び出されるか、改行文字が印字されるまで表示されない。これは、 特にデバッグ時において、予期しない結果を生じる原因となるかもしれない。 +標準ストリームの (あるいは他のすべてのストリームの) バッファリングモードは、 \fBsetbuf\fP(3) または \fBsetvbuf\fP(3) +を呼び出すことによって変更できる。 ただし、 \fIstdin\fP が端末に接続されているときは、端末のドライバでバッファリングされている +可能性がある点にも注意すること。これは stdio のバッファリングとは全く 関係なく存在しうる。 (実際、通常だと端末入力はカーネルによって行単位 +でバッファリングされている。) このカーネルによる入力の扱いは \fBtcsetattr\fP(3) などの呼び出しによって変更することができる。 +\fBstty\fP(1) と \fBtermios\fP(3) も参照すること。 .SH 関連項目 -.BR csh (1), -.BR sh (1), -.BR open (2), -.BR fopen (3), -.BR stdio (3) +\fBcsh\fP(1), \fBsh\fP(1), \fBopen\fP(2), \fBfopen\fP(3), \fBstdio\fP(3)