GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PERROR (3)

NAME

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

CONTENTS

Library
Synopsis
Description
See Also
Standards
History
Bugs

LIBRARY


.Lb libc

SYNOPSIS


.In stdio.h void perror const char *string
.Vt extern const char * const sys_errlist[] ;
.Vt extern const int sys_nerr ;
.In string.h char * strerror int errnum int strerror_r int errnum char *strerrbuf size_t buflen

DESCRIPTION

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 printed.

If the error number is not recognized, these functions return an error message string containing "Unknown error: " followed by the error number in decimal. The strerror and strerror_r functions return EINVAL as a warning. Error numbers recognized by this implementation fall in the range 0 < errnum < sys_nerr. The number 0 is also recognized, although applications that take advantage of this are likely to use unspecified values of errno.

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

intro(2), err(3), psignal(3)

STANDARDS

The perror and strerror functions conform to -isoC-99. The strerror_r function conforms to -p1003.1-2001.

HISTORY

The strerror and perror functions first appeared in BSD 4.4 . The strerror_r function was implemented in
.Fx 4.4 by
.An Wes Peters Aq wes@FreeBSD.org .

BUGS

The strerror function returns its result in a static buffer which will be overwritten by subsequent calls.

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

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

Search for    or go to Top of page |  Section 3 |  Main Index


Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.