Commit | Line | Data |
---|---|---|
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 | 10 | perror, 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 | 25 | produces a short error message on the standard error file |
b65a3479 | 26 | describing the last error encountered during a call |
81d13c8c KB |
27 | to the system from a C program. If |
28 | .I string | |
29 | is non-NULL, it is printed, followed by a colon, followed by a space, | |
1cc9f117 KB |
30 | followed by the message and a new-line. Otherwise, just the |
31 | message and the new-line are printed. Most usefully, the argument | |
32 | string is the name of the program which incurred the error. | |
b65a3479 KM |
33 | The error number is taken from the external variable |
34 | .I errno | |
35 | (see | |
36 | .IR intro (2)), | |
37 | which is set when errors occur but not cleared when | |
38 | non-erroneous calls are made. | |
39 | .PP | |
81d13c8c KB |
40 | To simplify variant formatting of messages, the |
41 | .I strerror | |
42 | function returns a pointer to the error message string mapped | |
43 | to the error number | |
44 | .IR errnum . | |
45 | .PP | |
46 | The message strings can be accessed directly using the external | |
47 | character array | |
48 | .IR sys_errlist . | |
b65a3479 | 49 | .I Sys_nerr |
81d13c8c KB |
50 | is the total number of messages in the array. The use of these |
51 | variables is deprecated; | |
52 | .I strerror | |
53 | should be used instead. | |
b65a3479 | 54 | .SH "SEE ALSO" |
81d13c8c | 55 | intro(2) |