PERROR(3C-SysV) RISC/os Reference Manual PERROR(3C-SysV)
NAME
perror, errno, sys_errlist, sys_nerr - system error messages
SYNOPSIS
#include <bsd/sys/types.h>
void perror (s)
char *s;
extern int errno;
extern char *syserrlist[ ];
extern int sysnerr;
extern char *syserrnolist[ ];
extern int sysnerrno;
DESCRIPTION
perror produces a message on the standard error output,
describing the last error encountered during a call to a
system or library function.
By default, the message printed consists of the text given
by the argument to perror, followed by a colon and a space
if the text is non-empty, followed by the system message
corresponding to the error number. The error number is
taken from the external variable errno, which is set when
errors occur but not cleared when non-erroneous calls are
made. All error messages end with a newline.
The environment variable PERROR_FMT can be set to a non-
empty string containing the format of the error message.
Text from the string is copied as-is except for a set of %-
specifiers described below:
%p The standard message as described above.
%t The argument to perror.
%c A colon (:) if the argument to perror is nonempty;
otherwise an empty string.
%s A colon (:) followed by a space if the argument to
perror is nonempty; otherwise an empty string.
%m The system message that corresponds to the error
number.
%e The symbolic name for the error number.
Printed 1/15/91 Page 1
PERROR(3C-SysV) RISC/os Reference Manual PERROR(3C-SysV)
%n The error number.
%% The character %.
A % followed by any other character causes the % and the
character to be printed.
As an example, assume that perror is called after a failed
call to open(2) that sets the error number to 2, and that
the argument to perror is ``myfile''. If PERROR_FMT is ``%t
%s%m - (%e)'', the resulting message will be
myfile : No such file or directory - (ENOENT)
To simplify variant formatting of messages, the array of
message strings syserrlist and the array is provided; errno
can be used as an index into these tables to get the strings
without the new-line. sysnerr and sysnerrno are the
number of messages in the tables; they should be checked
because new error codes may be added to the system before
they are added to the tables. Note that in future releases
of this system, a routine will be provided to return the
formatted message without the newline, so that programs that
need to format messages can do so.
SEE ALSO
intro(2).
ERRORS
Many programs do not use perror so the formatting is not
always useful. These programs should be fixed.
Page 2 Printed 1/15/91