*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> strerror (3)              



NAME    [Toc]    [Back]

     perror, strerror, strerror_r, sys_errlist, sys_nerr -- system error messages

LIBRARY    [Toc]    [Back]

     Standard C Library (libc, -lc)

SYNOPSIS    [Toc]    [Back]

     #include <stdio.h>

     perror(const char *string);

     extern const char * const sys_errlist[];
     extern const int sys_nerr;

     #include <string.h>

     char *
     strerror(int errnum);

     strerror_r(int errnum, char *strerrbuf, size_t buflen);

DESCRIPTION    [Toc]    [Back]

     The strerror(), strerror_r() and perror() functions look up the error
     message string corresponding to an error number.

     The strerror() function accepts an error number argument errnum and
     returns a pointer to the corresponding message string.

     The strerror_r() function renders the same result into strerrbuf for a
     maximum of buflen characters and returns 0 upon success.

     The perror() function finds the error message corresponding to the current
 value of the global variable errno (intro(2)) and writes it, followed
 by a newline, to the standard error file descriptor.  If the argument
 string is non-NULL and does not point to the null character, this
     string is prepended to the message string and separated from it by a
     colon and space (``: ''); otherwise, only the error message string is

     If errnum is not a recognized error number, strerror() returns an error
     message string containing ``Unknown error: '' followed by the error number
 in decimal, while strerror_r() leaves strerrbuf unchanged and returns
     EINVAL.  Error numbers recognized by this implementation fall in the
     range 0 < errnum < sys_nerr.

     If insufficient storage is provided in strerrbuf (as specified in buflen)
     to contain the error string, strerror_r() returns ERANGE and strerrbuf
     will contain an error message that has been truncated and NUL terminated
     to fit the length specified by buflen.

     The message strings can be accessed directly using the external array
     sys_errlist.  The external value sys_nerr contains a count of the messages
 in sys_errlist.  The use of these variables is deprecated;
     strerror() or strerror_r() should be used instead.

SEE ALSO    [Toc]    [Back]

     intro(2), psignal(3)

STANDARDS    [Toc]    [Back]

     The perror() and strerror() functions conform to ISO/IEC 9899:1999
     (``ISO C99'').  The strerror_r() function conforms to IEEE Std
     1003.1-2001 (``POSIX.1'').

HISTORY    [Toc]    [Back]

     The strerror() and perror() functions first appeared in 4.4BSD.  The
     strerror_r() function was implemented in FreeBSD 4.4 by Wes Peters

BUGS    [Toc]    [Back]

     For unknown error numbers, the strerror() function will return its result
     in a static buffer which may be overwritten by subsequent calls.

     The return type for strerror() is missing a type-qualifier; it should
     actually be const char *.

     Programs that use the deprecated sys_errlist variable often fail to compile
 because they declare it inconsistently.

FreeBSD 5.2.1		       December 19, 2002		 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
perror IRIX get system error messages
perror IRIX print system error messages
dmesg HP-UX collect system diagnostic messages to form error log
perror OpenBSD write error messages to standard error
perror NetBSD write error messages to standard error
writesrv Tru64 Lets users send messages to and receive messages from a remote system
err FreeBSD formatted error messages
niserror HP-UX display NIS+ error messages
warn FreeBSD formatted error messages
ERR_print_errors_fp OpenBSD print error messages
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service