- 论坛徽章:
- 0
|
如果函数执行成功会返回读到的字节数,如果到达文件尾,则返回0.当实际读到的数据字节数小于参数中指定的字节数时,会有以下几种情况:
- When reading from a regular file, if the end
of file is reached before the requested number of bytes has been read.
For example, if 30 bytes remain until the end of file and we try to
read 100 bytes, read returns 30. The next time we call read, it will return 0 (end of file).
- When reading from a terminal device. Normally, up to one line is read at a time.
- When reading from a network. Buffering within the network may cause less than the requested amount to be returned.
- When reading from a pipe or FIFO. If the pipe contains fewer bytes than requested, read will return only what is available.
- When
reading from a record-oriented device. Some record-oriented devices,
such as magnetic tape, can return up to a single record at a time.
- When interrupted by a signal and a partial amount of data has already been read.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/87597/showart_2151929.html |
|