当前位置:网站首页>Detailed explanation of errno
Detailed explanation of errno
2022-07-19 01:51:00 【tissar】
errno Detailed explanation
effect
errno yes error number Abbreviation , It means the system call error code .
If the system call returns success ,errno It is possible, but not necessarily 0; When the system call fails ,errno It must be set to the corresponding error number . therefore , OCD patients can call the system call before , Manual will errno Set up 0. however , If the system call returns success , Who will be free to see errno Well ?
Correlation function
Generally speaking , Do we need to know each errno What does the number of mean . We will use two C Library functions help us translate errno That's what it means .
They are :
#include <string.h>
char *strerror(int errnum);
#include <stdio.h>
void perror(const char *msg);
Multithreading
Before multithreading ,errno It's actually a global variable . It's easy to understand , But it's past tense .
Because every thread may call system calls , Then the subsequent mistakes , It will cover the previous errors . If we can't guarantee errno The reliability of the , that errno What's the point? ?
therefore , It has changed .
- When multithreading , Need to include header file
#include <errno.h> - errno It is no longer a global variable , Now it has become a macro
although errno Changed , But it's still an lvalue ( The left value can be written as “ The left value = Right value ” In the form of ).
What the hell is this macro ? Don't wait to decompose , Let's keep looking :
extern int *__errno_location(void);
#define errno (*__errno_location())
First , Declared functions from outside __errno_location(); Watch out! , The return value of this function is a function pointer , This pointer points to the thread's own errno The location of , By dereferencing this pointer , You can access the thread only errno.
therefore ,errno Is defined as (*__errno_location()).
边栏推荐
- Today, the code farmer girl made notes about the life cycle and practiced the dynamic clock
- 基于移动终端的MIMO阵列三维成像技术
- Classification and use of express Middleware
- The following packages have unmet dependencies: deepin.com.wechat:i386 : Depends: deepin-wine:i386
- Xcode11添加引导页(升级后Launch Images Source选项不见了)
- 走好数据中台最后一公里,为什么说数据服务API是数据中台的标配?
- js 树状图数组批量循环操作
- How to use express and how to match and use routes
- 记录一次海外图片加载不出来的排查
- Swift - 泛型
猜你喜欢

JVM 判断对象已死,实践验证GC回收

axs火爆,还有哪些打金游戏(上)

DHFS读写流程

争夺存量用户关键战,助力企业构建完美标签体系丨01期直播回顾

微信公众号网页授权40029错误「建议收藏」

Countless times of stepping on the pit to install awvs

Recurrence of yii2 deserialization vulnerability

Dhfs read / write process

【文献阅读】Small-Footprint Keyword Spotting with Multi-Scale Temporal Convolution

Solve the problem that Scala cannot initialize the class of native
随机推荐
Iptables and snort basic configuration
Xcode11添加引导页(升级后Launch Images Source选项不见了)
mysql innodb 事务相关记录
Owl Eyes: Spotting UI Display Issues via Visual Understanding
Classification and use of express Middleware
14:07:08 ckati failed with: signal: killed
touchID 和 FaceID~1
The following packages have unmet dependencies: deepin.com.wechat:i386 : Depends: deepin-wine:i386
Byte two side: what is pseudo sharing? How to avoid it?
How to use express and how to match and use routes
MapReduce
防抖debounce和节流throttle的使用
1章 性能平台GodEye源码分析-整体架构
Countless times of stepping on the pit to install awvs
Common asynchronous sending code writing
Namenode and secondarynamenode
JVM 判断对象已死,实践验证GC回收
Show Me the Code之MXNet网络模型(三)
golang编译的常见错误
【MySQL】windows安装MySQL 5.6