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
42       The  error  numbers  that  correspond to each symbolic name vary across
43       UNIX systems, and even across different architectures on Linux.  There‐
44       fore,  numeric  values  are  not  included as part of the list of error
45       names below.  The perror(3) and strerror(3) functions can  be  used  to
46       convert these names to corresponding textual error messages.
47
48       On  any  particular Linux system, one can obtain a list of all symbolic
49       error names and the corresponding error numbers using the errno(1) com‐
50       mand (part of the moreutils package):
51
52           $ errno -l
53           EPERM 1 Operation not permitted
54           ENOENT 2 No such file or directory
55           ESRCH 3 No such process
56           EINTR 4 Interrupted system call
57           EIO 5 Input/output error
58           ...
59
60       The  errno(1) command can also be used to look up individual error num‐
61       bers and names, and to search for errors using strings from  the  error
62       description, as in the following examples:
63
64           $ errno 2
65           ENOENT 2 No such file or directory
66           $ errno ESRCH
67           ESRCH 3 No such process
68           $ errno -s permission
69           EACCES 13 Permission denied
70
71   List of error names
72       In the list of the symbolic error names below, various names are marked
73       as follows:
74
75       *  POSIX.1-2001: The name is defined by POSIX.1-2001, and is defined in
76          later POSIX.1 versions, unless otherwise indicated.
77
78       *  POSIX.1-2008:  The  name  is  defined  in  POSIX.1-2008, but was not
79          present in earlier POSIX.1 standards.
80
81       *  C99: The name is defined by C99.  Below is a list  of  the  symbolic
82          error names that are defined on Linux:
83
84       E2BIG           Argument list too long (POSIX.1-2001).
85
86       EACCES          Permission denied (POSIX.1-2001).
87
88       EADDRINUSE      Address already in use (POSIX.1-2001).
89
90       EADDRNOTAVAIL   Address not available (POSIX.1-2001).
91
92       EAFNOSUPPORT    Address family not supported (POSIX.1-2001).
93
94       EAGAIN          Resource temporarily unavailable (may be the same value
95                       as EWOULDBLOCK) (POSIX.1-2001).
96
97       EALREADY        Connection already in progress (POSIX.1-2001).
98
99       EBADE           Invalid exchange.
100
101       EBADF           Bad file descriptor (POSIX.1-2001).
102
103       EBADFD          File descriptor in bad state.
104
105       EBADMSG         Bad message (POSIX.1-2001).
106
107       EBADR           Invalid request descriptor.
108
109       EBADRQC         Invalid request code.
110
111       EBADSLT         Invalid slot.
112
113       EBUSY           Device or resource busy (POSIX.1-2001).
114
115       ECANCELED       Operation canceled (POSIX.1-2001).
116
117       ECHILD          No child processes (POSIX.1-2001).
118
119       ECHRNG          Channel number out of range.
120
121       ECOMM           Communication error on send.
122
123       ECONNABORTED    Connection aborted (POSIX.1-2001).
124
125       ECONNREFUSED    Connection refused (POSIX.1-2001).
126
127       ECONNRESET      Connection reset (POSIX.1-2001).
128
129       EDEADLK         Resource deadlock avoided (POSIX.1-2001).
130
131       EDEADLOCK       Synonym for EDEADLK.
132
133       EDESTADDRREQ    Destination address required (POSIX.1-2001).
134
135       EDOM            Mathematics  argument  out  of   domain   of   function
136                       (POSIX.1, C99).
137
138       EDQUOT          Disk quota exceeded (POSIX.1-2001).
139
140       EEXIST          File exists (POSIX.1-2001).
141
142       EFAULT          Bad address (POSIX.1-2001).
143
144       EFBIG           File too large (POSIX.1-2001).
145
146       EHOSTDOWN       Host is down.
147
148       EHOSTUNREACH    Host is unreachable (POSIX.1-2001).
149
150       EHWPOISON       Memory page has hardware error.
151
152       EIDRM           Identifier removed (POSIX.1-2001).
153
154       EILSEQ          Invalid  or  incomplete  multibyte  or  wide  character
155                       (POSIX.1, C99).
156
157                       The text shown here is the glibc error description;  in
158                       POSIX.1,  this  error  is  described  as  "Illegal byte
159                       sequence".
160
161       EINPROGRESS     Operation in progress (POSIX.1-2001).
162
163       EINTR           Interrupted  function  call  (POSIX.1-2001);  see  sig‐
164                       nal(7).
165
166       EINVAL          Invalid argument (POSIX.1-2001).
167
168       EIO             Input/output error (POSIX.1-2001).
169
170       EISCONN         Socket is connected (POSIX.1-2001).
171
172       EISDIR          Is a directory (POSIX.1-2001).
173
174       EISNAM          Is a named type file.
175
176       EKEYEXPIRED     Key has expired.
177
178       EKEYREJECTED    Key was rejected by service.
179
180       EKEYREVOKED     Key has been revoked.
181
182       EL2HLT          Level 2 halted.
183
184       EL2NSYNC        Level 2 not synchronized.
185
186       EL3HLT          Level 3 halted.
187
188       EL3RST          Level 3 reset.
189
190       ELIBACC         Cannot access a needed shared library.
191
192       ELIBBAD         Accessing a corrupted shared library.
193
194       ELIBMAX         Attempting to link in too many shared libraries.
195
196       ELIBSCN         .lib section in a.out corrupted
197
198       ELIBEXEC        Cannot exec a shared library directly.
199
200       ELNRANGE        Link number out of range.
201
202       ELOOP           Too many levels of symbolic links (POSIX.1-2001).
203
204       EMEDIUMTYPE     Wrong medium type.
205
206       EMFILE          Too many open files (POSIX.1-2001).  Commonly caused by
207                       exceeding the RLIMIT_NOFILE resource limit described in
208                       getrlimit(2).
209
210       EMLINK          Too many links (POSIX.1-2001).
211
212       EMSGSIZE        Message too long (POSIX.1-2001).
213
214       EMULTIHOP       Multihop attempted (POSIX.1-2001).
215
216       ENAMETOOLONG    Filename too long (POSIX.1-2001).
217
218       ENETDOWN        Network is down (POSIX.1-2001).
219
220       ENETRESET       Connection aborted by network (POSIX.1-2001).
221
222       ENETUNREACH     Network unreachable (POSIX.1-2001).
223
224       ENFILE          Too  many  open  files  in  system  (POSIX.1-2001).  On
225                       Linux, this is probably a result  of  encountering  the
226                       /proc/sys/fs/file-max limit (see proc(5)).
227
228       ENOANO          No anode.
229
230       ENOBUFS         No   buffer   space  available  (POSIX.1  (XSI  STREAMS
231                       option)).
232
233       ENODATA         No message is available on the STREAM head  read  queue
234                       (POSIX.1-2001).
235
236       ENODEV          No such device (POSIX.1-2001).
237
238       ENOENT          No such file or directory (POSIX.1-2001).
239
240                       Typically, this error results when a specified pathname
241                       does not exist, or one of the components in the  direc‐
242                       tory prefix of a pathname does not exist, or the speci‐
243                       fied pathname is a dangling symbolic link.
244
245       ENOEXEC         Exec format error (POSIX.1-2001).
246
247       ENOKEY          Required key not available.
248
249       ENOLCK          No locks available (POSIX.1-2001).
250
251       ENOLINK         Link has been severed (POSIX.1-2001).
252
253       ENOMEDIUM       No medium found.
254
255       ENOMEM          Not enough space/cannot allocate memory (POSIX.1-2001).
256
257       ENOMSG          No message of the desired type (POSIX.1-2001).
258
259       ENONET          Machine is not on the network.
260
261       ENOPKG          Package not installed.
262
263       ENOPROTOOPT     Protocol not available (POSIX.1-2001).
264
265       ENOSPC          No space left on device (POSIX.1-2001).
266
267       ENOSR           No STREAM resources (POSIX.1 (XSI STREAMS option)).
268
269       ENOSTR          Not a STREAM (POSIX.1 (XSI STREAMS option)).
270
271       ENOSYS          Function not implemented (POSIX.1-2001).
272
273       ENOTBLK         Block device required.
274
275       ENOTCONN        The socket is not connected (POSIX.1-2001).
276
277       ENOTDIR         Not a directory (POSIX.1-2001).
278
279       ENOTEMPTY       Directory not empty (POSIX.1-2001).
280
281       ENOTRECOVERABLE State not recoverable (POSIX.1-2008).
282
283       ENOTSOCK        Not a socket (POSIX.1-2001).
284
285       ENOTSUP         Operation not supported (POSIX.1-2001).
286
287       ENOTTY          Inappropriate I/O control operation (POSIX.1-2001).
288
289       ENOTUNIQ        Name not unique on network.
290
291       ENXIO           No such device or address (POSIX.1-2001).
292
293       EOPNOTSUPP      Operation not supported on socket (POSIX.1-2001).
294
295                       (ENOTSUP and EOPNOTSUPP have the same value  on  Linux,
296                       but  according  to POSIX.1 these error values should be
297                       distinct.)
298
299       EOVERFLOW       Value  too  large   to   be   stored   in   data   type
300                       (POSIX.1-2001).
301
302       EOWNERDEAD      Owner died (POSIX.1-2008).
303
304       EPERM           Operation not permitted (POSIX.1-2001).
305
306       EPFNOSUPPORT    Protocol family not supported.
307
308       EPIPE           Broken pipe (POSIX.1-2001).
309
310       EPROTO          Protocol error (POSIX.1-2001).
311
312       EPROTONOSUPPORT Protocol not supported (POSIX.1-2001).
313
314       EPROTOTYPE      Protocol wrong type for socket (POSIX.1-2001).
315
316       ERANGE          Result too large (POSIX.1, C99).
317
318       EREMCHG         Remote address changed.
319
320       EREMOTE         Object is remote.
321
322       EREMOTEIO       Remote I/O error.
323
324       ERESTART        Interrupted system call should be restarted.
325
326       ERFKILL         Operation not possible due to RF-kill.
327
328       EROFS           Read-only filesystem (POSIX.1-2001).
329
330       ESHUTDOWN       Cannot send after transport endpoint shutdown.
331
332       ESPIPE          Invalid seek (POSIX.1-2001).
333
334       ESOCKTNOSUPPORT Socket type not supported.
335
336       ESRCH           No such process (POSIX.1-2001).
337
338       ESTALE          Stale file handle (POSIX.1-2001).
339
340                       This error can occur for NFS and for other filesystems.
341
342       ESTRPIPE        Streams pipe error.
343
344       ETIME           Timer expired (POSIX.1 (XSI STREAMS option)).
345
346                       (POSIX.1 says "STREAM ioctl(2) timeout".)
347
348       ETIMEDOUT       Connection timed out (POSIX.1-2001).
349
350       ETOOMANYREFS    Too many references: cannot splice.
351
352       ETXTBSY         Text file busy (POSIX.1-2001).
353
354       EUCLEAN         Structure needs cleaning.
355
356       EUNATCH         Protocol driver not attached.
357
358       EUSERS          Too many users.
359
360       EWOULDBLOCK     Operation  would  block  (may  be same value as EAGAIN)
361                       (POSIX.1-2001).
362
363       EXDEV           Improper link (POSIX.1-2001).
364
365       EXFULL          Exchange full.
366

NOTES

368       A common mistake is to do
369
370           if (somecall() == -1) {
371               printf("somecall() failed\n");
372               if (errno == ...) { ... }
373           }
374
375       where errno no longer needs to have the value it had upon  return  from
376       somecall()  (i.e.,  it may have been changed by the printf(3)).  If the
377       value of errno should be preserved across a library call,  it  must  be
378       saved:
379
380           if (somecall() == -1) {
381               int errsv = errno;
382               printf("somecall() failed\n");
383               if (errsv == ...) { ... }
384           }
385
386       On  some  ancient systems, <errno.h> was not present or did not declare
387       errno, so that it was necessary to declare errno manually (i.e., extern
388       int  errno).   Do not do this.  It long ago ceased to be necessary, and
389       it will cause problems with modern versions of the C library.
390

SEE ALSO

392       errno(1), err(3), error(3), perror(3), strerror(3)
393

COLOPHON

395       This page is part of release 5.02 of the Linux  man-pages  project.   A
396       description  of  the project, information about reporting bugs, and the
397       latest    version    of    this    page,    can     be     found     at
398       https://www.kernel.org/doc/man-pages/.
399
400
401
402                                  2019-03-06                          ERRNO(3)
Impressum