Contents|Index|Previous|Next

strerror
[convert error number to string]

SYNOPSIS
#include <string.h>
char *strerror(int errnum);

DESCRIPTION
strerror converts the error number errnum into a string. The value of errnum is usually a copy of errno. If errnum is not a known error number, the result points to an empty string.

This implementation of strerror prints out the following strings for each of the values defined in errno.h.

    E2BIG
    Arg list too long
    EACCES
    Permission denied
    EADV
    Advertise error
    EAGAIN
    No more processes
    EBADF
    Bad file number
    EBADMSG
    Bad message
    EBUSY
    Device or resource busy
    ECHILD
    No children
    ECOMM
    Communication error
    EDEADLK
    Deadlock
    EEXIST
    File exists
    EDOM
    Math argument
    EFAULT
    Bad address
    EFBIG
    File too large
    EIDRM
    Identifier removed
    EINTR
    Interrupted system call
    EINVAL
    Invalid argument
    EIO
    I/O error
    EISDIR
    Is a directory
    ELIBACC
    Cannot access a needed shared library
    ELIBBAD
    Accessing a corrupted shared library
    ELIBEXEC
    Cannot exec a shared library directly
    ELIBMAX
    Attempting to link in more shared libraries than system limit
    ELIBSCN
    .lib section in a.out corrupted
    EMFILE
    Too many open files
    EMLINK
    Too many links
    EMULTIHOP
    Multihop attempted
    ENAMETOOLONG
    File or path name too long
    ENFILE
    Too many open files in system
    ENODEV
    No such device
    ENOENT
    No such file or directory
    ENOEXEC
    Exec format error
    ENOLCK
    No lock
    ENOLINK
    Virtual circuit is gone
    ENOMEM
    Not enough space
    ENOMSG
    No message of desired type
    ENONET
    Machine is not on the network
    ENOPKG
    No package
    ENOSPC
    No space left on device
    ENOSR
    No stream resources
    ENOSTR
    Not a stream
    ENOSYS
    Function not implemented
    ENOTBLK
    Block device required
    ENOTDIR
    Not a directory
    ENOTEMPTY
    Directory not empty
    ENOTTY
    Not a character device
    ENXIO
    No such device or address
    EPERM
    Not owner
    EPIPE
    Broken pipe
    EPROTO
    Protocol error
    ERANGE
    Result too large
    EREMOTE
    Resource is remote
    EROFS
    Read-only file system
    ESPIPE
    Illegal seek
    ESRCH
    No such process
    ESRMNT
    Srmount error
    ETIME
    Stream ioctl timeout
    ETXTBSY
    Text file busy
    EXDEV
    Cross-device link

RETURNS
This function returns a pointer to a string. Your application must not modify that string.

COMPLIANCE
ANSI C requires strerror, but does not specify the strings used for each error number.

Although this implementation of strerror is reentrant, ANSI C declares that subsequent calls to strerror may overwrite the result string; therefore portable code cannot depend on the reentrancy of this subroutine.

This implementation of strerror provides for user-defined extensibility. errno.h defines __ELASTERROR, which can be used as a base for user-defined error values. If the user supplies a routine named _user_ strerror, and errnum passed to strerror does not match any of the supported values, _user_strerror is called with errnum as its argument. _user_strerror takes one argument of type int, and returns a character pointer. If errnum is unknown to _user_strerror, _user_strerror returns NULL. The default _user_strerror returns NULL for all input values.

strerror requires no supporting OS subroutines.