Questions tagged [errno]

errno is an integer variable, 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 return value of the call indicated an error.

errno is an integer variable, 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 return value of the call indicated an error.

559 questions
14
votes
2 answers

Difference between Linux errno 23 and Linux errno 24

What is the difference between these 2 linux errors in errno.h? 23 and 24 I tried 2 different sites but can't understand difference between the two. [EMFILE] Too many open files. [ENFILE] Too many files open in system. # define ENFILE 23 …
badri
  • 575
  • 2
  • 8
  • 22
14
votes
3 answers

How to set errno in Linux device driver?

I am designing a Linux character device driver. I want to set errno when error occurs in ioctl() system call. long my_own_ioctl(struct file *file, unsigned int req, unsigned long arg) { long ret = 0; BOOL isErr = FALSE; // some…
Andrew Chang
  • 1,289
  • 1
  • 18
  • 38
14
votes
12 answers

Symbolic errno to String

Is there a command-line tool that will take a symbolic errno such as EINVAL and print the corresponding string, Invalid argument? I would like to avoid having to find that EINVAL is value 22 on my system and then using$ perror 22. Ideally I could…
Flame
  • 2,166
  • 2
  • 20
  • 40
14
votes
2 answers

sprintf() negative return value and errno

According to http://linux.die.net/man/3/sprintf and http://www.cplusplus.com/reference/cstdio/sprintf/ sprintf() and family return the number of characters written on success. On failure, a negative value is returned. I would assume that an error…
Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
14
votes
2 answers

Using errno for application / library error reporting

I'm writing a C library for a software project. I need to do some error reporting, but I'm a little bit too lazy to implement my own complex set of error-codes, variables and functions. Is it acceptable to use the errno facility provided by the libc…
fuz
  • 88,405
  • 25
  • 200
  • 352
13
votes
4 answers

Access C global variable 'errno' from C#

Is it possible to access the "errno" variable in C# when P/Invoking? This is similar to Win32 GetLastError().
joemoe
  • 5,734
  • 10
  • 43
  • 60
13
votes
7 answers

How can I print the symbolic name of an errno in C?

I can use perror() or strerror() to print the "human readable" error message belonging to an errno, but what if I also want to print the symbolic name (e.g., "EAGAIN") of the errno? Any convenient function or macro to do that? Edit from the future:…
Will
  • 2,014
  • 2
  • 19
  • 42
13
votes
2 answers

Get Errno from Python Requests ConnectionError?

I'm catching and printing Python Requests ConnectionErrors fine with just this: except requests.exceptions.ConnectionError as e: logger.warning(str(e.message)) It prints out messages such as: HTTPSConnectionPool(host='10.100.24.16', port=443):…
ArtOfWarfare
  • 20,617
  • 19
  • 137
  • 193
13
votes
4 answers

Error in Python IOError: [Errno 2] No such file or directory: 'data.csv'

In Python, I have a script, I'm trying to use the python open("data.csv") command to open a CSV file that I have in the Python script directory. There is a file there called data.csv. The python script indicates an error: Error in Python IOError:…
Doug Fir
  • 19,971
  • 47
  • 169
  • 299
12
votes
6 answers

Should my library handle SIGSEGV on bad pointer input?

I'm writing a small library that takes a FILE * pointer as input. If I immediately check this FILE * pointer and find it leads to a segfault, is it more correct to handle the signal, set errno, and exit gracefully; or to do nothing and use the…
User123abc
  • 376
  • 3
  • 9
12
votes
2 answers

Convert errno.h error values to Win32 GetLastError() equivalents

I'm writing a layer between a POSIX filesystem, and Windows using Dokan, and need to convert error values of the errno kind (EINVAL, ENOENT, etc.), to the Win32 equivalents you'd receive when calling GetLastError() (such as…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
12
votes
3 answers

In which header file are EINVAL, ENOMEM, etc. defined in Linux?

It’s said that the error numbers like EINVAL, ENOMEM, etc. are defined in errno.h, but I can’t find them in errno.h, I also searched some directories under /usr/include, still can’t find them. I can use these macros without any issue in my C code.…
oldnavy
  • 177
  • 1
  • 3
  • 9
12
votes
1 answer

Is it safe to assume errno to be always positive?

I am writing a program in which most of the used library functions return -1 on error and set errno. The behaviour of the program is such that it exits if error occurs. To determine exact exit point and the error from outside the program (example…
0xF1
  • 6,046
  • 2
  • 27
  • 50
12
votes
2 answers

Program exit status conventions

What is conventional return values for applications in Windows and GNU/Linux respectivly. 0 means success. But what should be used on user-requested abort. When I abort on Windows, it returns 3, but this value is not in the list of system error…
user877329
  • 6,717
  • 8
  • 46
  • 88
11
votes
2 answers

Should I use system_category or generic_category for errno on Unix?

C++0x has two predefined error_category objects: generic_category() and system_category(). From what I have understood so far, system_category() should be used for errors returned by the operating system, and generic_category() should be used for…
CesarB
  • 43,947
  • 7
  • 63
  • 86
1 2
3
37 38