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 | .\" | |
4a3da11e | 5 | .\" @(#)strerror.3 6.6 (Berkeley) %G% |
b65a3479 | 6 | .\" |
4a3da11e | 7 | .TH STRERROR 3 "" |
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 | |
1382c0b2 KB |
13 | .ft B |
14 | extern int errno, sys_nerr; | |
15 | extern char *sys_errlist[]; | |
16 | ||
17 | #include <stdio.h> | |
18 | ||
19 | void perror(const char *string); | |
20 | ||
21 | char *strerror(int errnum); | |
22 | .ft R | |
b65a3479 KM |
23 | .fi |
24 | .SH DESCRIPTION | |
25 | .I Perror | |
bd7fd9b1 | 26 | produces a short error message on the standard error file |
b65a3479 | 27 | describing the last error encountered during a call |
81d13c8c KB |
28 | to the system from a C program. If |
29 | .I string | |
30 | is non-NULL, it is printed, followed by a colon, followed by a space, | |
1cc9f117 KB |
31 | followed by the message and a new-line. Otherwise, just the |
32 | message and the new-line are printed. Most usefully, the argument | |
33 | string is the name of the program which incurred the error. | |
b65a3479 KM |
34 | The error number is taken from the external variable |
35 | .I errno | |
36 | (see | |
37 | .IR intro (2)), | |
38 | which is set when errors occur but not cleared when | |
39 | non-erroneous calls are made. | |
40 | .PP | |
81d13c8c KB |
41 | To simplify variant formatting of messages, the |
42 | .I strerror | |
43 | function returns a pointer to the error message string mapped | |
44 | to the error number | |
45 | .IR errnum . | |
46 | .PP | |
47 | The message strings can be accessed directly using the external | |
48 | character array | |
49 | .IR sys_errlist . | |
b65a3479 | 50 | .I Sys_nerr |
4a3da11e KB |
51 | is the total number of messages in the array. |
52 | The use of these variables is deprecated; | |
81d13c8c KB |
53 | .I strerror |
54 | should be used instead. | |
b65a3479 | 55 | .SH "SEE ALSO" |
1382c0b2 | 56 | intro(2), psignal(3) |