BSD 4_3_Reno release
[unix-history] / usr / src / lib / libc / gen / perror.3
CommitLineData
b65a3479
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
1c15e888 5.\" @(#)perror.3 6.4 (Berkeley) 6/24/90
b65a3479 6.\"
1c15e888 7.TH PERROR 3 "June 24, 1990"
b65a3479
KM
8.UC 4
9.SH NAME
81d13c8c 10perror, strerror, sys_errlist, sys_nerr \- system error messages
b65a3479
KM
11.SH SYNOPSIS
12.nf
1cc9f117
KB
13.B perror(string)
14.B char *string;
b65a3479 15.PP
17d8c3b0 16.B char *
81d13c8c
KB
17.B strerror(errnum)
18.B int errnum;
19.PP
20.B extern int errno, sys_nerr;
21.B extern char *sys_errlist[];
b65a3479
KM
22.fi
23.SH DESCRIPTION
24.I Perror
bd7fd9b1 25produces a short error message on the standard error file
b65a3479 26describing the last error encountered during a call
81d13c8c
KB
27to the system from a C program. If
28.I string
29is non-NULL, it is printed, followed by a colon, followed by a space,
1cc9f117
KB
30followed by the message and a new-line. Otherwise, just the
31message and the new-line are printed. Most usefully, the argument
32string is the name of the program which incurred the error.
b65a3479
KM
33The error number is taken from the external variable
34.I errno
35(see
36.IR intro (2)),
37which is set when errors occur but not cleared when
38non-erroneous calls are made.
39.PP
81d13c8c
KB
40To simplify variant formatting of messages, the
41.I strerror
42function returns a pointer to the error message string mapped
43to the error number
44.IR errnum .
45.PP
46The message strings can be accessed directly using the external
47character array
48.IR sys_errlist .
b65a3479 49.I Sys_nerr
81d13c8c
KB
50is the total number of messages in the array. The use of these
51variables is deprecated;
52.I strerror
53should be used instead.
b65a3479 54.SH "SEE ALSO"
81d13c8c 55intro(2)