errno
- 网络错误编号;错误代码
-
They also set a global int variable called errno .
它们还设置名为errno的全局整数变量。
-
The generated signal can change the value of errno , and the program behaves unexpectedly .
这个生成的信号可能会改变errno的值,程序的行为会无法预计。
-
The standard errno values include
标准errno值包括
-
Saving and restoring the value of errno in the signal handler , as follows , can resolve the problem
如下,在信号处理器内保存和恢复errno的值,可以解决这一问题
-
In cases like this , it 's important to check your input data for sanity , or check errno after every call .
在此类情况下,检查输入数据以确保其完备性,或在每次调用后检查errno,这一点很重要。
-
Suppose a signal is generated during the very small time gap between setting the errno variable by the close system call and its return .
假定信号在close系统调用设置errno变量到其返回之前这一极小的时间片段内生成。
-
Most system headers contain at least this much information for the standard errno values , so don 't be afraid to take a look .
大多数系统头文件都至少包含标准errno值的这些信息,因此请放心地去了解这些信息。
-
It requires an integer argument , errno , which should be the actual value of the global errno variable .
它需要整数参数errno,该参数应该是全局errno变量的实际数值。
-
Let 's take a look at some additional error-related global variables and the standard defined by POSIX-1003.1 errno values .
让我们了解一些与错误相关的其他全局变量,以及由POSIX-1003.1errno值定义的标准。
-
Errno . h is needed for the declaration of errno , the global system call error number variable ( more on that below ) .
h是声明errno所需要的,errno是全局系统调用错误号变量(下面会有更多介绍)。
-
By doing this the write system call returns with the number of bytes it wrote before it got interrupted and the errno set to success .
在这样处理方式下,write系统调用返回被信号中断前已写的字节数,并将errno全局变量设置为成功。
-
The return value of the write call is the number of bytes written before the interruption , and the errno will be set to success .
write的返回值是在被中断前已写的字节数,全局变量errno设置为成功。
-
It can be run in one of two ways , either with a single command line argument , which should be an errno value , or without any arguments .
它能以两种方式之一运行,带单个命令行参数,该参数应该是errno值,或不带任何参数。
-
The next unused file descriptor is returned if the call is successful ; otherwise , - 1 is returned and errno is set accordingly .
如果调用成功,返回下一个未使用的文件描述符;否则,返回-1并相应地设置errno。
-
When errno is set to0 , you 've encountered no problems , except you can 't refer to this with a standard symbolic constant .
当errno设置为0时,将不会遇到任何问题,除非您无法用标准符号常量引用此设置。
-
If a failure has occurred , a-1 is returned ( and that failure can be understood through the use of the errno variable ) .
如果排队失败,则返回-1(通过使用errno变量可以了解失败的原因)。
-
From extern int errno ; to # include
请用文本编辑器,把src/error.h的第6行从externinterrno;改成include
-
Standard error codes can be found in / usr / include / sys / errno . h and can help indicate the cause of the error .
可以在/usr/include/sys/errno.h中找到标准的错误码,这有助于查明错误的原因。
-
The function returns a specific value ( or range of values ) to indicate an error , and the global variable errno is set to indicate the cause of the problem .
函数返回特定值(或值范围)以指明错误,且设置全局变量errno以指明问题的起因。
-
Remember , this dumps all of the additional implementation-defined ( that is , non-standard ) errno values supported by the system you 're using .
请记住,此操作会转储您正在使用的系统所支持的其他所有的实现定义(即,非标准)的errno值。
-
Let 's take a quick look at some code demonstrating errno and a couple of functions that you can use to transform that error code into something more human-readable .
让我们快速地了解一些代码演示errno的情况,并了解可用于将错误代码转换成可读性更强的内容的几个函数。
-
Note that this is not the sort of deadlock you get in multithreaded code & errno and its friends definitely can 't help you track those down .
请注意,这与从多线程代码中获得的死锁类型不同&errno及其相关项一定能够帮助您跟踪到这些。
-
The opendir () and readdir () functions both return NULL if a problem occurs and the errno global variable is set to indicate what went wrong .
在出现问题时,opendir()和readdir()函数都会返回NULL,并且将设置全局变量errno的值,以指出所出现的错误。
-
This command immediately removes the semaphore set and its data structures , awakening all waiting processes ( with an error return and errno set to EIDRM ) .
这个命令将立即删除信号量集及其数据结构,并唤醒所有正在等待的进程(如果发生错误,则返回,并将errno设置为EIDRM)。
-
The perror () and strerror () / strerror_r () functions are probably the most commonly used error reporting methods when dealing with standard errno values .
在处理标准errno值时,perror()和strerror()/strerrorr()函数可能是最常用的错误报告方法。
-
You can simulate this yourself by using a printf () call and the strerror () function , which returns a pointer to the textual representation of the current errno value .
您可以通过使用printf()调用和strerror()函数(该函数返回当前errno值的文字表示形式的指针)来模拟此程序。
-
Look for calls marked with # Err , indicating a non-zero return code , which you can look up in / usr / include / sys / errno . h.
应该寻找带Err标志的调用,这表示返回码非零,可以在/usr/include/sys/errno.h中查找返回码。
-
In this case , you 'll receive a SIGPIPE signal or , if this signal is blocked , the write function will return a-1 and set errno to EPIPE .
在这种情况下,接收SIGPIPE信号,或如果该信号阻塞,write函数将返回-1并设置errno为EPIPE。
-
If readdir () returns NULL and errno is0 ( sometimes called EOK or ENOERROR ), there are no more directory entries .
如果readdir()返回NULL,并且errno为0(有时也称为EOK或ENOERROR),则表示没有其他的目录条目。
-
You can access this variable by its actual name by including the header errno . h , which should be included in all C programs that use system calls ( or library functions that invoke system calls ) .
您可以通过包括头文件errno.h来用该变量的实际名称访问它,所有使用系统调用的C程序(或调用系统调用的库函数)都应该包括头文件errno.h。