www.delorie.com/djgpp/doc/libc/libc_293.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

errno

Syntax

 
#include <errno.h>

extern int errno;

Description

This variable is used to hold the value of the error of the last function call. The value might be one of the following:

0

No Error. Library functions never set errno to zero, but the startup code does that just before calling main (this is ANSI C requirement).

1

EDOM -- Numerical input to a function is out of range.

2

ERANGE -- Numerical output of a function is out of range.

3

E2BIG -- Argument list too long. system and the functions from the spawn family assign this to errno when the command line is too long (longer than 126-character limit when invoking non-DJGPP programs, or longer than the transfer buffer size when invoking DJGPP programs).

4

EACCES -- Permission denied. Attempt to write to a read-only file, or remove a non-empty directory, or open a directory as if it were a file, etc. In essence, it's a DOS way of saying "You can't do that, but I'm too stupid to know why."

5

EAGAIN -- Resource temporarily unavailable, try again later. Almost never used in DJGPP, except when DOS returns error code 3Dh ("network print queue full") 81h (NetWare4 "CWait children still running") or 9Bh (NetWare4 "unable to create another TCB").

6

EBADF -- Bad file descriptor: an invalid file handle passed to a library function.

7

EBUSY -- Resource busy. Attempt to remove current directory (including current directory on another drive), or when a networked resource, such as a drive, is in use by another process.

8

ECHILD -- No child processes. Returned by wait and waitpid, and by NetWare-related calls.

9

EDEADLK -- Resource deadlock avoided. Never used in DJGPP.

10

EEXIST -- File exists. Returned by open and mkdir when a file or directory by that name already exists.

11

EFAULT -- Bad address. A function was passed a bad pointer (like a NULL pointer).

12

EFBIG -- File too large. Never used in DJGPP.

13

EINTR -- Interrupted system call. system and the functions of the spawn family use that when the child program was interrupted by Ctrl-C. Also, when DOS returns the "fail on INT 24h" error code.

14

EINVAL -- Invalid argument. Any case when any argument to a library function is found to be invalid. Examples include invalid drive number, "." or ".." as one of the arguments to rename, syntax errors in the command line passed to system, etc.

15

EIO -- Input or output error. Low-level error in I/O operation, like bad disk block, damaged FAT, etc.

16

EISDIR -- Is a directory: an attempt to do something with a directory which is only allowed with regular files. DOS usually returns EACCES in these cases, but DJGPP sometimes assigns EISDIR to errno, like when rename is called to move a regular file over a directory, or when system or one of the spawn* functions are passed a name of a directory instead of an executable program.

17

EMFILE -- Too many open files in system (no more handles available). This usually means that the number specified by the `FILES=' directive in `CONFIG.SYS' is too small.

18

EMLINK -- Too many links. Not used in DJGPP (as DOS doesn't support hard links).

19

ENAMETOOLONG -- File name too long (longer than FILENAME_MAX, defined in `stdio.h').

20

ENFILE -- Too many open files. Never used in DJGPP.

21

ENODEV -- No such device. Attempt to access an invalid drive, or an invalid operation for the type of drive.

22

ENOENT -- No such file or directory.

23

ENOEXEC -- Unable to execute file. Returned by _dxe_load (when the argument names a file that isn't a valid DXE), and by NetWare-related calls which run programs remotely.

24

ENOLCK -- No locks available. Returned when the DOS file-locking functions cannot lock more files (due to overflow of the sharing buffer).

25

ENOMEM -- Not enough memory. Note that, unlike your expectations, malloc does NOT set errno to ENOMEM; however, several library functions that use malloc will do that when it returns a NULL pointer.

26

ENOSPC -- No space left on drive. DOS usually doesn't return this error, but write and _write do this for it, when they detect a full disk condition.

27

ENOSYS -- Function not implemented. Any system call that isn't supported by the underlying OS, like an LFN function when running on plain DOS.

28

ENOTDIR -- Not a directory. DOS never returns this code, but some library functions, like rename and _truename, do that if they expect a valid directory pathname, but get either an invalid (e.g. empty) pathname or a file that is not a directory.

29

ENOTEMPTY -- Directory not empty. DOS never returns this code, but rename does, when it is called to move a directory over an existing non-empty directory.

30

ENOTTY -- Inappropriate I/O control operation. The termios functions set errno to this when called on a device that is not a TTY.

31

ENXIO -- No such device or address. An operation attempted to reference a device (not a disk drive) that is invalid, or non-existent, or access a disk drive that exists but is empty.

32

EPERM -- Operation not permitted. Examples include: sharing or file lock violations; denial of access to networked resources; expired password or illegal login attempts via a network; too many or duplicate network redirections; etc.

33

EPIPE -- Broken pipe: attempt to write to a pipe with nobody to read it. This never happens in DJGPP.

34

EROFS -- Read-only file system: attempt to write to a read-only disk. Unfortunately, DOS almost never returns this code.

35

ESPIPE -- Invalid seek: attempt to seek on a pipe. Never happens in DJGPP, except for NetWare-related operations, since pipes are simulated with regular files in MS-DOS, and therefore are always seekable.

36

ESRCH -- No such process. Not used in DJGPP.

37

EXDEV -- Improper link. An attempt to rename a file across drives or create a cross-device hardlink.

38

ENMFILE -- No more files. findfirst and findnext assign this to errno when they exhaust the files in the directory. readdir does that as well.

39

ELOOP -- Too many levels of symbolic links. Can be set virtually by any file handling function in library. Usually means encountered link loop (link1 -> link2, link2 -> link1).

40

EOVERFLOW -- Value too large. filelength can assign this to errno when a file's length is larger than 2^31-2 (see section filelength). lfilelength can assign this to errno when a file's length is larger than 2^63-1 (see section lfilelength).

41

EILSEQ -- Invalid or incomplete multibyte or wide character.

See section perror.

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004