errno

error: use of undeclared identifier 'errno_t'

倾然丶 夕夏残阳落幕 提交于 2019-12-18 05:47:21
问题 Here is my dead simple dummy code: #include <errno.h> int main(void) { errno_t e; return 0; } Which surprisingly raises this error: main.c:5:5: error: use of undeclared identifier 'errno_t' errno_t x; ^ I started to follow the traces : when the compiler sees the <...> inclusions it will first look at /usr/include where of course I found errno.h file. Actually it has a single line in it, besides the license comment, which is: #include <sys/errno.h> Now, at /usr/include/sys in errno.h I found

How to check the value of errno?

三世轮回 提交于 2019-12-18 03:40:45
问题 I am using a system call and in case it fails, I need to do different things for different errnos. I need to write code that looks something like this: int res; res = systemCall(); if (res == -1) { if (errno == ENOMSG) { doSomething(); } else { doSomethingElse(); } } perror doesn't help, because it only prints the value. As for strerro - if it is what I need, I am not suer how to use it, because here it says that the actual string is not the same as the error. Quote from the man page: "(For

TCP Connect error 115 Operation in Progress What is the Cause?

百般思念 提交于 2019-12-17 23:27:48
问题 My application creats a TCP connection, This is working normaly. But in one network server has many IP say 174.X.X.X 54.x.x.x like this When calling TCP connect (Non blocking with timeout of 60 seconds) to IP 174.X.X.X is always success . But TCP connect to same server with ip 54.x.x.x is failing (most of the times) with errno 115 measn operation in progress. Can you please explain me what are the possible reason for errno 115 OS : Linux My TCP conenct code is as below tcp_connect(......) {

Should I set errno?

你离开我真会死。 提交于 2019-12-17 22:43:49
问题 I'm writing a module which exports an interface similar to send and recv . Since those functions are supposed to return respectively the number of sent and received bytes, I cannot do proper error management as I would do normally (i.e. using enumeratives and returning mnemonic values). In a situation like this should I set errno as the standard library does? If so, since errno is thread specific, is there a particular way of writing on it, or can I simply assign a value to it? Edit:

How to catch Errno::ECONNRESET class in “case when”?

佐手、 提交于 2019-12-17 22:38:17
问题 My application (Ruby 1.9.2) may raise different exceptions, including net-connection breaks. I rescue Exception => e , then do case/when to handle them in defferent ways, but several errors go through my cases straight to else . rescue Exception => e p e.class case e.class when Errno::ECONNRESET p 1 when Errno::ECONNRESET,Errno::ECONNABORTED,Errno::ETIMEDOUT p 2 else p 3 end end Prints: Errno::ECONNRESET 3 回答1: This is because of how the === operator works on the class Class The case

Is there a way to use errno safely in a multi-threaded application? [duplicate]

旧时模样 提交于 2019-12-17 18:25:20
问题 This question already has answers here : Is errno thread-safe? (8 answers) Closed last year . If you are writing a multi-threaded application that uses system/library calls that make use of errno to indicate the error type, is there a safe way to use errno? If not, is there some other way to indicate the type of error that occurred rather than just that an error has occurred? 回答1: If your standard library is multithread aware, then it probably has a #define that changes errno into a function

What does this socket.gaierror mean?

时光总嘲笑我的痴心妄想 提交于 2019-12-17 16:24:45
问题 I'm new to python and going through a book, Core Python Applications 3rd Edition. This is the the first example and already I'm stumped with it. Here's the code with the error at the end. #!/usr/bin/env python from socket import * from time import ctime HOST = ' ' PORT = 21567 BUFSIZ = 1024 ADDR = (HOST, PORT) tcpSerSock = socket(AF_INET, SOCK_STREAM) tcpSerSock.bind(ADDR) tcpSerSock.listen(5) while True: print 'waiting for connection...' tcpCliSock, addr = tcpSerSock.accept() print "..

C 标准库 - 《errno.h》

血红的双手。 提交于 2019-12-16 11:45:19
原文链接 https://www.runoob.com/cprogramming/c-standard-library-errno-h.html 简介 C 标准库的 errno.h 头文件定义了整数变量 errno ,它是通过系统调用设置的,在错误事件中的某些库函数表明了什么发生了错误。该宏扩展为类型为 int 的可更改的左值,因此它可以被一个程序读取和修改。 在程序启动时, errno 设置为零,C 标准库中的特定函数修改它的值为一些非零值以表示某些类型的错误。您也可以在适当的时候修改它的值或重置为零。 errno.h 头文件定义了一系列表示不同错误代码的宏,这些宏应扩展为类型为 int 的整数常量表达式。 库宏 下面列出了头文件 errno.h 中定义的宏: 序号 宏 & 描述 1 extern int errno 这是通过系统调用设置的宏,在错误事件中的某些库函数表明了什么发生了错误。 2 EDOM Domain Error 这个宏表示一个域错误,它在输入参数超出数学函数定义的域时发生,errno 被设置为 EDOM。 3 ERANGE Range Error 这个宏表示一个范围错误,它在输入参数超出数学函数定义的范围时发生,errno 被设置为 ERANGE。 来源: CSDN 作者: 老狼主 链接: https://blog.csdn.net/u012156872

PermissionError: [Errno 13] Permission denied:

故事扮演 提交于 2019-12-13 23:22:06
问题 I'm trying to write in a txt file the vertices of a spline mesh, but I get this error: PermissionError: [Errno 13] Permission denied: 'C\:Windows\system32\vt_84.txt The code is 回答1: Try at a different location. Since you are trying to edit a file kept at C:Windows\system32 location, you are getting this error. also, check your path. It should be like C:\Windows\system32\vt_84.txt 回答2: If it's an existing file, make sure that it isn't open anywhere 来源: https://stackoverflow.com/questions

FIFO Issue with concurrent processes

帅比萌擦擦* 提交于 2019-12-13 19:43:47
问题 PRETEND THEY'RE NOT PARENT AND CHILD PROCESSES EVEN THOUGH THEY ARE. MAKE FIFO: /* Create response FIFO. */ if (mkfifo(RESP_FIFO_NAME, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", RESP_FIFO_NAME); exit(1); } } Fork: /* 3. Fork the client process. */ switch (fork()) { /* Fork failed. */ case (pid_t) -1: fprintf(stderr, "Call to fork failed.\n"); exit(1); /* Client (child) process. */ case 0: execlp(CLIENT_NAME, CLIENT_NAME, argv[SERVER_CMD