fclose 中文man页面

系统
函数 fclose 将名为 stream 的流与它底层关联的文件或功能集合断开。如果流曾用作输出,任何缓冲的数据都将首先被写入,使用 fflush(3) 。

NAME

fclose - 关闭流  

SYNOPSIS 总览

#include <stdio.h>

int fclose(FILE *stream);  

DESCRIPTION 描述

函数 fclose 将名为 stream 的流与它底层关联的文件或功能集合断开。如果流曾用作输出,任何缓冲的数据都将首先被写入,使用 fflush(3) 。  

RETURN VALUE 返回值

成功执行返回 0,否则返回 EOF 并设置全局变量 errno 来指示错误发生。任何一种情况下,对流再进行存取 (包括再次调用 fclose()) 都会带来未定义的结果。  

ERRORS

EBADF
stream 底层的文件描述符是无效的。

函数 fclose 也可能失败并置 errnoclose(2), write(2) 或 fflush(3) 指定的值。  

NOTES 要点

注意 fclose 仅仅刷新用户空间的由 C 库提供的缓冲。要保证数据被物理地存储到磁盘上,必须也刷新内核缓冲。例如,使用 sync(2) 或 fsync(2).  

CONFORMING TO 标准参考

函数 fclose 遵循 ANSI X3.159-1989 (``ANSI C'') 标准。  

SEE ALSO 参见

close(2), fcloseall(3), fflush(3), fopen(3), setbuf(3)

#p#

NAME

fclose - close a stream  

SYNOPSIS

#include <stdio.h>

int fclose(FILE *stream);  

DESCRIPTION

The fclose function dissociates the named stream from its underlying file or set of functions. If the stream was being used for output, any buffered data is written first, using fflush(3).  

RETURN VALUE

Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the error. In either case any further access (including another call to fclose()) to the stream results in undefined behaviour.  

ERRORS

EBADF
The filedescriptor underlying stream is not valid.

The fclose function may also fail and set errno for any of the errors specified for the routines close(2), write(2) or fflush(3).  

NOTES

Note that fclose only flushes the user space buffers provided by the C library. To ensure that the data is physically stored on disk the kernel buffers must be flushed too, e.g. with sync(2) or fsync(2).  

CONFORMING TO

The fclose function conforms to ANSI X3.159-1989 (``ANSI C'').  

SEE ALSO

close(2), fcloseall(3), fflush(3), fopen(3), setbuf(3)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-12 14:58:05

killall中文man

2011-07-15 16:58:36

ac中文man

2011-08-15 11:10:48

more中文man

2011-08-25 17:03:51

pclose中文man

2011-08-15 14:10:37

tar中文man

2011-08-16 10:42:30

rmmod中文man

2011-08-18 13:57:38

acct中文man

2011-08-23 17:49:36

zdump中文man

2011-08-15 15:10:49

wall中文man

2011-08-23 15:06:03

quotastats中文man

2011-08-15 17:35:50

ar中文man

2011-08-25 09:07:16

suffixes中文man

2011-08-18 15:21:37

autofs中文man

2011-08-25 15:19:39

dirname中文man

2011-08-25 17:34:50

setlinebuf中文man

2011-08-15 15:17:14

ac中文man
点赞
收藏

51CTO技术栈公众号