errno(2)
NAME
errno − introduction error numbers
SYNTAX
#include <errno.h>
DESCRIPTION
The errno is an external variable whose value is set whenever an error occurs in a system call. This value can be used to obtain a more detailed description of the error. The errno is not cleared on successful system calls, so its value should be checked only when an error has been indicated.
RETURN VALUE
Most system calls have one or more return values. An error condition is indicated by an otherwise impossible return value. This is almost always −1; the individual descriptions specify the details.
All return codes and values from functions are of type integer unless otherwise noted. An error number is also made available in the external variable errno which is not cleared on successful calls. Thus errno should be tested only after an error has occurred.
Here is a list of the errors and their names as given in <errno.h>.
0 Error 0
Unused.
1 EPERM Not owner
Typically this error indicates an attempt to modify a file in some way forbidden except to its owner or superuser. It is also returned for attempts by ordinary users to do things allowed only to the superuser.
2 ENOENT No such file or directory
This error occurs when a file name is specified and the file should exist but does not, or when one of the directories in a pathname does not exist.
3 ESRCH No such process
The process whose number was given to kill() and ptrace() does not exist or is already dead.
4 EINTR Interrupted system call
An asynchronous signal (such as interrupt or quit), which the user has elected to catch, occurred during a system call. If execution is resumed after processing the signal, it will appear as if the interrupted system call returned this error condition.
5 EIO I/O error
Some physical I/O error occurred during a read or write. This error may occur on a call following the one to which it actually applies.
6 ENXIO No such device or address
I/O on a special file refers to a subdevice that does not exist or beyond the limits of the device. It may also occur when an illegal tape drive unit number is selected or a disk pack is not loaded on a drive.
7 E2BIG Arg list too long
An argument list longer than 10240 bytes is presented to execve(.).
8 ENOEXEC Exec format error
A request is made to execute a file that does not start with a valid magic number, although it has the appropriate permissions. For further information, see a.out(.).
9 EBADF Bad file number
Either a file descriptor refers to no open file or a read (respectively, write) request is made to a file which is open only for writing (respectively, reading).
10 ECHILD No children
A wait and the process has no living or unwaited-for children.
11 EAGAIN No more processes
In a fork, the system’s process table is full or the user is not allowed to create any more processes.
12 ENOMEM Not enough core
During an execve() or brk, a program asks for more core or swap space than the system is able to supply. A lack of swap space is normally a temporary condition. However, a lack of core is not a temporary condition; the maximum size of the text, data, and stack segments is a system parameter.
13 EACCES Permission denied
An attempt was made to access a file in some way forbidden by the protection system.
14 EFAULT Bad address
The system encountered a hardware fault in attempting to access the arguments of a system call.
15 ENOTBLK Block device required
A plain file was mentioned where a block device was required, for example, in mount(.).
16 EBUSY Mount device busy
An attempt was made to mount a device that was already mounted or to unmount a device on which there was an active file directory, an open file, current directory, mounted-on file, or active text segment. Or, an attempt was made to modify a partition table incorrectly. See the restrictions in chpt(.).
17 EEXIST File exists
An existing file was mentioned in an inappropriate context.
18 EXDEV Cross-device link
A hard link to a file on another device was attempted.
19 ENODEV No such device
An attempt was made to apply an inappropriate system call to a device; for example, read a write-only device.
20 ENOTDIR Not a directory
A non-directory was specified where a directory is required, for example in a path name or as an argument to chdir(.).
21 EISDIR Is a directory
An attempt to write on a directory.
22 EINVAL Invalid argument
An invalid argument: dismounting a non-mounted device, mentioning an unknown signal in signal(,), reading or writing a file for which seek has generated a negative pointer. Also set by math functions, see intro(.).
23 ENFILE File table overflow
The system’s table of open files is full, and temporarily no more opens can be accepted.
24 EMFILE Too many open files
Customary configuration limit is 20 files per process.
25 ENOTTY Not a typewriter
The file mentioned in an ioctl() is not a terminal or one of the other devices to which these calls apply.
26 ETXTBSY Text file busy
An attempt to execute a pure-procedure program which is currently open for writing or reading. Also an attempt to open for writing a pure-procedure program that is being executed.
27 EFBIG File too large
The size of a file exceeded the maximum (about 109 bytes).
28 ENOSPC No space left on device
During a write to an ordinary file, there is no free space left on the device.
29 ESPIPE Illegal seek
An lseek() was issued to a pipe. This error may also be issued for other non-seekable devices.
30 EROFS Restricted operation on a file system
An attempt to access a file or directory on a mounted file system when that permission has been revoked. For example, trying to write a file on a file system mounted read only.
31 EMLINK Too many links
An attempt to make more than 32767 hard links to a file.
32 EPIPE Broken pipe
A write on a pipe or socket for which there is no process to read the data. This condition normally generates a signal; the error is returned if the signal is ignored.
33 EDOM Argument too large
The argument of a function in the math package Section (3m) is out of the domain of the function.
34 ERANGE Result too large
The value of a function in the math package Section (3m) is unrepresentable within machine precision.
35 EWOULDBLOCK Operation would block
An operation which would cause a process to block was attempted on a object in non-blocking mode. For further information, see ioctl(.).
36 EINPROGRESS Operation now in progress
An operation which takes a long time to complete, such as connect(,), was attempted on a non-blocking object. For further information, see ioctl(.).
37 EALREADY Operation already in progress
An operation was attempted on a non-blocking object which already had an operation in progress.
38 ENOTSOCK Socket operation on non-socket
Self-explanatory.
39 EDESTADDRREQ Destination address required
A required address was omitted from an operation on a socket.
40 EMSGSIZE Message too long
A message sent on a socket was larger than the internal message buffer.
41 EPROTOTYPE Protocol wrong type for socket
A protocol was specified which does not support the semantics of the socket type requested. For example you cannot use the ARPA Internet UDP protocol with type SOCK_STREAM.
42 ENOPROTOOPT Protocol not available
A bad option was specified in a getsockopt() or setsockopt() call.
43 EPROTONOSUPPORT Protocol not supported
The protocol has not been configured into the system or no implementation for it exists.
44 ESOCKTNOSUPPORT Socket type not supported
The support for the socket type has not been configured into the system or no implementation for it exists.
45 EOPNOTSUPP Error−operation not supported
For example, trying to accept a connection on a datagram socket.
46 EPFNOSUPPORT Protocol family not supported
The protocol family has not been configured into the system or no implementation for it exists.
47 EAFNOSUPPORT Address family not supported by protocol family
An address incompatible with the requested protocol was used. For example, you should not expect to be able to use PUP Internet addresses with ARPA Internet protocols.
48 EADDRINUSE Address already in use
Each address can be used only once.
49 EADDRNOTAVAIL Can’t assign requested address
Normally results from an attempt to create a socket with an address not on this machine.
50 ENETDOWN Network is down
A socket operation encountered a dead network.
51 ENETUNREACH Network is unreachable
A socket operation was attempted to an unreachable network.
52 ENETRESET Network dropped connection on reset
The host you were connected to crashed and rebooted.
53 ECONNABORTED Software caused connection abort
A connection abort was caused internal to your host machine.
54 ECONNRESET Connection reset by peer
A connection was forcibly closed by a peer. This usually results from the peer executing a shutdown() call.
55 ENOBUFS No buffer space available
An operation on a socket or pipe was not performed because the system lacked sufficient buffer space.
56 EISCONN Socket is already connected
A connect request was made on an already connected socket; or, a sendto or sendmsg request on a connected socket specified a destination other than the connected party.
57 ENOTCONN Socket is not connected
An request to send or receive data was disallowed because the socket is not connected.
58 ESHUTDOWN Can’t send after socket shutdown
A request to send data was disallowed because the socket had already been shut down with a previous shutdown() call.
59 ETOOMANYREFS Too many references: can’t splice
60 ETIMEDOUT Connection timed out
A connect request failed because the connected party did not properly respond after a period of time. (The timeout period is dependent on the communication protocol.) A connect request or remote file operation failed because the connected party did not properly respond after a period of time which is dependent on the communication protocol. For example, this occurs when an NFS file system is mounted with the “soft” option and the server is not responding to file operation requests.
61 ECONNREFUSED Connection refused
No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service which is inactive on the foreign host.
62 ELOOP Too many levels of symbolic links
A path name lookup involved more than 8 symbolic links.
63 ENAMETOOLONG File name too long
A component of a path name exceeded 255 characters, or an entire path name exceeded 1023 characters.
64 EHOSTDOWN Host is down
A socket operation failed because the destination host was down.
65 EHOSTUNREACH No route to host
A socket operation was attempted to an unreachable host.
66 ENOTEMPTY Directory not empty
A directory with entries other than “.” and “..” was supplied to a remove directory or rename call.
67 EPROCLIM Too many processes
The user would exceed the number of user processes that are available. This limit can be changed by changing the maxuprc option in the configuration file when the kernel is built.
68 EUSERS Too many users
This error is returned when a login process would exceed the maximum allowable login processes that the system is licensed for.
69 EDQUOT Disk quota exceeded
A write to an ordinary file, the creation of a directory or symbolic link, or the creation of a directory entry failed because the user’s quota of disk blocks was exhausted, or the allocation of an inode for a newly created file failed because the user’s quota of inodes was exhausted.
70 ESTALE
An NFS stale file handle. Information used by the operating system to identify a file in an NFS file system is no longer valid. This error code results from operating on a remote file that no longer exists on the server or resides in a file system that has been moved to a different device on the server.
71 EREMOTE
Remote NFS client has requested an operation on a file that is remote to the server as well. An attempt has been made to mount an NFS remote file system that is not local to the specified server. This error code cannot occur except in response to a failed mount(.).
72 ENOMSG No message of desired type
An attempt was made to receive a message of a type that does not exist on the specified message queue. For further information, see msgop(.).
73 EIDRM Identifier removed
In semaphores, shared memory, or message queues, the caller tried to access the identifier after it had been removed from the system.
74 EALIGN alignment error
Alignment error of some type, for example, cluster, page, or block.