148351Scael.\" Copyright (c) 1980, 1991 Regents of the University of California. 248351Scael.\" All rights reserved. 320436Smckusick.\" 4*50314Sbostic.\" This code is derived from software contributed to Berkeley by 5*50314Sbostic.\" the American National Standards Committee X3, on Information 6*50314Sbostic.\" Processing Systems. 7*50314Sbostic.\" 848351Scael.\" %sccs.include.redist.man% 920436Smckusick.\" 10*50314Sbostic.\" @(#)strerror.3 6.9 (Berkeley) 06/29/91 1148351Scael.\" 1248351Scael.Dd 1348351Scael.Dt STRERROR 3 1448351Scael.Os BSD 4 1548351Scael.Sh NAME 1648351Scael.Nm perror , 1748351Scael.Nm strerror , 1848351Scael.Nm sys_errlist , 1948351Scael.Nm sys_nerr 2048351Scael.Nd system error messages 2148351Scael.Sh SYNOPSIS 2248351Scael.Vt extern int errno; 2348351Scael.Vt extern char *sys_errlist[]; 2448351Scael.Fd #include <stdio.h> 2548351Scael.Ft void 2648351Scael.Fn perror "const char *string" 2748351Scael.Ft char * 2848351Scael.Fn strerror "int errnum" 2948351Scael.Sh DESCRIPTION 3048351ScaelThe 3148351Scael.Fn strerror 3248351Scaeland 3348351Scael.Fn perror 3448351Scaelfunctions lookup the error message string affiliated with an 3548351Scaelerror number. 3648351Scael.Pp 3748351ScaelThe 3848351Scael.Fn sterror 3948351Scaelfunction accepts an error number argument 4048351Scael.Fa errnum 4148351Scaeland 4248351Scaelreturns a pointer to the corresponding 4348351Scaelmessage string. 4448351Scael.Pp 4548351ScaelThe 4648351Scael.Fn perror 4748351Scaelfunction finds the error message corresponding to the current 4848351Scaelvalue of the global variable 4948351Scael.Va errno 5048351Scaeland writes it, followed by a new-line, to the 5148351Scael.Em stderr . 5248351ScaelIf the argument 5348351Scael.Fa string 5448351Scaelis 5548351Scael.Pf non- Dv NULL 5648351Scaelit is pre-appended to the message 5748351Scaelstring and separated from it by 5848351Scaela colon and space 5948351Scael.Pq Ql \&:\ \& . 6048351ScaelIf 6148351Scael.Fa string 6248351Scaelis 6348351Scael.Dv NULL 6448351Scaelonly the error message string is printed. 6548351Scael.Pp 6636225SbosticThe message strings can be accessed directly using the external 6736225Sbosticcharacter array 6848351Scael.Fa sys_errlist . 6948351ScaelThe external value 7048351Scael.Fa sys_nerr 7148351Scaelcontains a count of the messages in 7248351Scael.Fa sys_errlist . 7347016SbosticThe use of these variables is deprecated; 7448351Scael.Fn strerror 7536225Sbosticshould be used instead. 7648351Scael.Sh SEE ALSO 7748351Scael.Xr intro 2 , 7848351Scael.Xr psignal 3 7948351Scael.Sh HISTORY 8048351ScaelThe 8148351Scael.Fn strerror 8248351Scaeland 8348351Scael.Fn perror 8448351Scaelfunctions are 8548351Scael.Ud . 86