PERROR(3C) SysV PERROR(3C)
NAME
perror, strerror, strerror_r, errno, sys_errlist, sys_nerr - system error
messages
SYNOPSIS
#include <stdio.h>
void perror(s)
const char *s;
#include <string.h>
char *strerror(errnum)
int errnum;
strerror_r (errnum, buffer, len)
int errnum;
char *buffer;
int len;
extern int errno;
extern char *sys_errlist[ ];
extern int sys_nerr;
DESCRIPTION
The perror function maps the error number in errno to an error message.
It generates a short error message on the standard error file, describing
the error encountered by a C program during its most recent call to the
system. If s is not null, and does not point to the null character,
perror prints s, followed by a colon and a blank. The error message,
terminated with a newline, is then printed, regardless of the value of s.
To be of most use, s should include the name of the program that incurred
the error.
The error message is selected from sys_errlist, using the value of the
external variable errno, which is set when errors occur but not cleared
by successful calls.
To simplify creation of variant formats, the vector of message strings
sys_errlist is provided. sys_nerr is the number of messages provided for
in the table. If errnum is less than sys_nerr, strerror returns an
address from sys_errlist pointing to a message string without the
newline. Otherwise, strerror returns a pointer to the string "Unknown
error". You should check sys_nerr because new error codes may be added to
the system before they are added to the table. Typically, the value
passed to strerror should be errno.
The contents of the error message strings are the same as those returned
by the strerror function.
The perror function marks the file associated with the standard error
error stream as having been written (st_ctime st_mtime marked for update)
at some time between its successful completion and the completion of
fflush(3) or fclose(3) on stderr, or exit(2) or abort(2).
The strerror function maps the error number in errnum to an error message
string and returns a pointer thereto. The string pointed to is not
modified by the program, but may be overwritten by a subsequent call to
the strerror function.
strerror_r is the reentrant version of the strerror function.
ERRORS
If strerror or strerror_r fails, errno may be set to the following value:
[EINVAL]
len is less than NL_TEXTMAX as specified in limits.h.
NOTES
More verbose, Domain/OS-specific error messages may be obtained by
setting the environment variable APOLLO_STATUS to "true".
SEE ALSO
<stdio.h>.