1ERRNO(3)                   Linux Programmer's Manual                  ERRNO(3)
2
3
4

NAME

6       errno - number of last error
7

SYNOPSIS

9       #include <errno.h>
10

DESCRIPTION

12       The  <errno.h> header file defines the integer variable errno, which is
13       set by system calls and some library functions in the event of an error
14       to indicate what went wrong.
15
16   errno
17       The  value  in  errno  is significant only when the return value of the
18       call indicated an error (i.e., -1 from most system calls;  -1  or  NULL
19       from  most  library  functions); a function that succeeds is allowed to
20       change errno.  The value of errno is never set to zero  by  any  system
21       call or library function.
22
23       For  some system calls and library functions (e.g., getpriority(2)), -1
24       is a valid return on success.  In such cases, a successful  return  can
25       be  distinguished  from an error return by setting errno to zero before
26       the call, and then, if the call returns a status that indicates that an
27       error may have occurred, checking to see if errno has a nonzero value.
28
29       errno  is  defined  by  the ISO C standard to be a modifiable lvalue of
30       type int, and must not be explicitly declared; errno may  be  a  macro.
31       errno  is  thread-local;  setting  it in one thread does not affect its
32       value in any other thread.
33
34   Error numbers and names
35       Valid error numbers are all positive  numbers.   The  <errno.h>  header
36       file defines symbolic names for each of the possible error numbers that
37       may appear in errno.
38
39       All the error names specified by POSIX.1  must  have  distinct  values,
40       with  the  exception  of EAGAIN and EWOULDBLOCK, which may be the same.
41       On Linux, these two have the same value on all architectures.
42
43       The error numbers that correspond to each  symbolic  name  vary  across
44       UNIX systems, and even across different architectures on Linux.  There‐
45       fore, numeric values are not included as part  of  the  list  of  error
46       names  below.   The  perror(3) and strerror(3) functions can be used to
47       convert these names to corresponding textual error messages.
48
49       On any particular Linux system, one can obtain a list of  all  symbolic
50       error names and the corresponding error numbers using the errno(1) com‐
51       mand (part of the moreutils package):
52
53           $ errno -l
54           EPERM 1 Operation not permitted
55           ENOENT 2 No such file or directory
56           ESRCH 3 No such process
57           EINTR 4 Interrupted system call
58           EIO 5 Input/output error
59           ...
60
61       The errno(1) command can also be used to look up individual error  num‐
62       bers  and  names, and to search for errors using strings from the error
63       description, as in the following examples:
64
65           $ errno 2