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