OSDN Git Service

e39596bc940ef84fe299aa40e66fb7bc0bece494
[linuxjm/LDP_man-pages.git] / draft / man3 / fclose.3
1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Chris Torek and the American National Standards Committee X3,
6 .\" on Information Processing Systems.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)fclose.3    6.7 (Berkeley) 6/29/91
37 .\"
38 .\" Converted for Linux, Mon Nov 29 15:19:14 1993, faith@cs.unc.edu
39 .\"
40 .\" Modified 2000-07-22 by Nicolas Lichtmaier <nick@debian.org>
41 .\"
42 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
43 .\"       all rights reserved.
44 .\" Translated Mon Jan 20 18:30:47 JST 1997
45 .\"       by Takashi Yoshino <tyoshino@eng.toyo.ac.jp>
46 .\" Updated Mon Sep 25 01:58:44 JST 2000
47 .\"       by Kentaro Shirakata <argrath@ub32.org>
48 .\" Updated & Modified Tue Apr  3 20:49:00 JST 2001
49 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
50 .\" Updated & Modified Mon Jan 10 08:08:29 JST 2005
51 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
52 .\"
53 .TH FCLOSE 3  2009-02-23 "GNU" "Linux Programmer's Manual"
54 .\"O .SH NAME
55 .SH 名前
56 .\"O fclose \- close a stream
57 fclose \- ストリームを閉じる
58 .\"O .SH SYNOPSIS
59 .SH 書式
60 .B #include <stdio.h>
61 .sp
62 .BI "int fclose(FILE *" fp );
63 .\"O .SH DESCRIPTION
64 .SH 説明
65 .\"O The
66 .\"O .BR fclose ()
67 .\"O function will flushes the stream pointed to by
68 .\"O .I fp
69 .\"O (writing any buffered output data using
70 .\"O .BR fflush (3))
71 .\"O and closes the underlying file descriptor.
72 .BR fclose ()
73 関数は
74 .I fp
75 で指されるストリームを (バッファリングされていた全ての出力データを
76 .BR fflush (3)
77 を用いて書き込んで) フラッシュし、
78 その基となるファイルディスクリプタをクローズする。
79 .\"O .SH "RETURN VALUES"
80 .SH 返り値
81 .\"O Upon successful completion 0 is returned.
82 関数が正常に終了すると 0 が返される。
83 .\"O Otherwise,
84 .\"O .B EOF
85 .\"O is returned and
86 .\"O .I errno
87 .\"O is set to indicate the error.
88 正常に終了しなかった場合には
89 .B EOF
90 が返され、
91 .I errno
92 がエラーを示すために設定される。
93 .\"O In either case any further access
94 .\"O (including another call to
95 .\"O .BR fclose ())
96 .\"O to the stream results in undefined behavior.
97 どちらの場合も、そのストリームに対する
98 .RB ( fclose ()
99 へのさらなる呼び出しを含む) それ以上のアクセスは
100 未定義の動作を生じさせる。
101 .\"O .SH ERRORS
102 .SH エラー
103 .TP
104 .B EBADF
105 .\"O The file descriptor underlying
106 .\"O .I fp
107 .\"O is not valid.
108 .I fp
109 の基となるファイルディスクリプタが不正である。
110 .\"O .\"  This error cannot occur unless you are mixing ANSI C stdio operations and
111 .\"O .\"  low-level file operations on the same stream. If you do get this error,
112 .\"O .\"  you must have closed the stream's low-level file descriptor using
113 .\"O .\"  something like close(fileno(fp)).
114 .\"  同じストリームに対して ANSI C stdio の操作と低レベルファイル操作を
115 .\"  取り混ぜて行わない限り、このエラーは起こらない。
116 .\"  このエラーを受け取ったのは、ストリームの低レベルファイルディスクリプタを、
117 .\"  close(fileno(fp)) などで、既にクローズしてしまったからに違いない。
118 .PP
119 .\"O The
120 .\"O .BR fclose ()
121 .\"O function may also fail and set
122 .\"O .I errno
123 .\"O for any of the errors specified for the routines
124 .\"O .BR close (2),
125 .\"O .BR write (2)
126 .\"O or
127 .\"O .BR fflush (3).
128 .BR fclose ()
129 関数はこれ以外にも
130 .BR close (2),
131 .BR write (2),
132 .BR fflush (3)
133 のルーチンで失敗することがある。その場合は
134 .I errno
135 が、失敗したルーチンで設定された値に設定される。
136 .\"O .SH "CONFORMING TO"
137 .SH 準拠
138 C89, C99.
139 .\"O .SH NOTES
140 .SH 注意
141 .\"O Note that
142 .\"O .BR fclose ()
143 .\"O only flushes the user space buffers provided by the
144 .\"O C library.
145 .\"O To ensure that the data is physically stored
146 .\"O on disk the kernel buffers must be flushed too, for example, with
147 .\"O .BR sync (2)
148 .\"O or
149 .\"O .BR fsync (2).
150 .BR fclose ()
151 は C ライブラリで提供されたユーザー空間バッファをフラッシュするだけで
152 ある点に注意すること。
153 データを確実に物理的にディスクに記録するためには
154 カーネルバッファも
155 .RB ( sync (2)
156
157 .BR fsync (2)
158 を用いて) フラッシュしなければならない。
159 .\"O .SH SEE ALSO
160 .SH 関連項目
161 .BR close (2),
162 .BR fcloseall (3),
163 .BR fflush (3),
164 .BR fopen (3),
165 .BR setbuf (3)