免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2690 | 回复: 3
打印 上一主题 下一主题

关于errno [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-08-09 15:02 |只看该作者 |倒序浏览
DESCRIPTION
       The  <errno.h> header file defines the integer variable errno, which is set by system calls and some library functions in
       the event of an error to indicate what went wrong.  Its value is significant only when the call returned an  error  (usu鈥[m
       ally -1), and a function that does succeed is allowed to change errno.

       Sometimes,  when -1 is also a valid successful return value one has to zero errno before the call in order to detect pos鈥[m
       sible errors.

       errno is defined by the ISO C standard to be a modifiable lvalue of type int, and must not be explicitly declared;  errno
       may be a macro.  errno is thread-local; setting it in one thread does not affect its value in any other thread.       Valid  error numbers are all non-zero; errno is never set to zero by any library function.  All the error names specified
       by POSIX.1 must have distinct values, with the exception of EAGAIN and EWOULDBLOCK, which may be the same.

       Below is a list of the symbolic error names that are defined on Linux.  Some of these are marked POSIX.1, indicating that
       the name is defined by POSIX.1-2001, or C99, indicating that the name is defined by C99.


errno是线程本地存储的?
另外如果recv系统调用导致errno被设置为EINTER,其它的系统调用如果调用成功了,errno有时会被设置为0,有时还是旧值,怎么回事情啊?

论坛徽章:
6
金牛座
日期:2013-10-08 10:19:10技术图书徽章
日期:2013-10-14 16:24:09CU十二周年纪念徽章
日期:2013-10-24 15:41:34狮子座
日期:2013-11-24 19:26:19未羊
日期:2014-01-23 15:50:002015年亚洲杯之阿联酋
日期:2015-05-09 14:36:15
2 [报告]
发表于 2011-08-09 16:11 |只看该作者
回复 1# phoxia
errno是线程存储的。
errno不会被置成0。

论坛徽章:
0
3 [报告]
发表于 2011-08-10 09:47 |只看该作者
线程存储的话,那么如果开10个线程,每个线程的errno都可能不同么?

论坛徽章:
6
金牛座
日期:2013-10-08 10:19:10技术图书徽章
日期:2013-10-14 16:24:09CU十二周年纪念徽章
日期:2013-10-24 15:41:34狮子座
日期:2013-11-24 19:26:19未羊
日期:2014-01-23 15:50:002015年亚洲杯之阿联酋
日期:2015-05-09 14:36:15
4 [报告]
发表于 2011-08-11 14:50 |只看该作者
回复 3# phoxia
因为是线程存储的,所以不同的线程errno的值是有可能不相同的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP