When calling
execl(...)
, I get an errno=2
. What does it mean? How can I know the meaning of this errno
?BarthBarth
We are in the process of updating our website the Man fault codes will be loaded soon. Please contact our service department for assistance and fault codes. 83 Heidelberg Road, Production Park, City Deep, Johannesburg, Gauteng, South Africa. Tel: +27 011 405 0600. Fax: +27 011 613 8107. Description of fault codes for ERGO-Control 97-09-18 3 table of fault codes Fault Code (hex) MEANING OF THE FAULT CODE possible reason for fault detection reaction of the TCU possible steps to repair remarks 11 LOGICAL ERROR AT GEAR RANGE SIGNAL TCU detected a wrong signal combination for the gear range. cable from shift lever to TCU is broken.
15 Answers
You can use
strerror()
to get a human-readable string for the error number. This is the same string printed by perror()
but it's useful if you're formatting the error message for something other than standard error output.For example:
Linux also supports the explicitly-threadsafe variant
strerror_r()
. user283145
Commodore JaegerCommodore Jaeger
Instead of running
perror
on any error code you get, you can retrieve a complete listing of errno
values on your system with the following one-liner:cpp -dM /usr/include/errno.h | grep 'define E' | sort -n -k 3
Josh KelleyJosh Kelley
On Linux there is also a very neat tool that can tell right away what each error code means. On Ubuntu:
apt-get install errno
.Then if for example you want to get the description of error type 2, just type
errno 2
in the terminal.With
errno -l
you get a list with all errors and their descriptions. Much easier that other methods mentioned by previous posters.PithikosPithikos
Here is the output from
errno -l
reformatted for readability:I used tabularise in Vim to align the columns:
joeytwiddlejoeytwiddle
Error code 2 means 'File/Directory not found'. In general, you could use the perror function to print a human readable string.
user283145
schnaaderschnaader
There's a few useful functions for dealing with
errno
s. (Just to make it clear, these are built-in to libc
-- I'm just providing sample implementations because some people find reading code clearer than reading English.)strerror
returns a string describing the error number you've passed to it. Caution, this is not thread- or interrupt-safe; it is free to rewrite the string and return the same pointer on the next invocation. Use strerror_r
if you need to worry about that.perror
prints out the message you give it, plus a string describing the current errno
, to standard error.ephemientephemient
This is faster than looking up the code in
errno.h
, shorter than most solutions posted here and it does not require installation of third party tools:perl -E 'say $!=shift' 2
yields
No such file or directory
LCCLCC
Works on Solaris.
cc perror.c -o perror
<< use this line to compile itJohan SnowgooseJohan Snowgoose
Here is the documentation. That should tell you what it means and what to do with them. You should avoid using the numeric value and use the constants listed there as well, as the number may change between different systems.
dsmdsm
user25148
Call
in case of error.
Sample:
The manpages of
errno(3)
and perror(3)
are interesting, too...Johannes WeissJohannes Weiss
Type
sudo apt-get install moreutils
and then once that has installed, type errno 2
. You can also use errno -l
for all error numbers, or see only the file ones by piping it to grep
, like this: errno | grep file
.carefulnow1carefulnow1
When you use strace (on Linux) to run your binary, it will output the returns from system calls and what the error number means. This may sometimes be useful to you.
Sarel BothaSarel Botha
I have the following function in my .bashrc file - it looks up the errno value from the header files (can be either
/usr/include/errno.h
, /usr/include/linux/errno.h
, etc., etc.)It works if header files are installed on the machine;-)
Usually the header file have an error + next comes the explanation in the comment; something of the following:
./asm-generic/errno-base.h:#define EAGAIN 11 /* Try again */
MichaelMoserMichaelMoser
Otávio DécioOtávio Décio