流上哪些可能的错误条件会导致 ferror() 被设置? [英] What are the possible error conditions on a stream that will cause ferror() to be set?
问题描述
一些从流读取和写入的操作可能会在流中设置错误标志,可以使用 ferror(stream)
进行测试,虽然我很确定这一定是一个常见问题,我无法在 SO 或一般网络中找到所有可能的错误原因列表.什么可能导致 ferror() 被设置?
Some operations to read and write from streams may set the error flag in a stream, which can be tested using ferror(stream)
, while I'm quite sure this must be a frequently asked question, I wasn't able to find a list of all the possible causes of errors in SO or in the general web. What could cause ferror() to be set?
特别是,我正在寻找在 Minix 3 的标准输入上执行 fgets() 时可能导致错误的原因,但我也在寻找更一般的列表.
In particular, I'm looking for the possible causes of errors when doing fgets() on the standard input on Minix 3, but I'm looking for a more general list as well.
推荐答案
没有任何可能的错误的简单列表.但是,根据您正在读取或写入的设备,问题可能包括:
There isn't any simple list of possible errors. However, depending on the device you're reading from or writing to, the problems could include:
- 设备出现故障(短路、过热、老化……)
- 设备已从机器中拔出(U 盘)
- 设备已关闭或断电(外部磁盘驱动器)
- 设备被弹出(CD-ROM)
- 网络连接丢失(SAN、NAS)
- 设备已满(没有剩余空间用于写入)
- ...
这篇关于流上哪些可能的错误条件会导致 ferror() 被设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!