158450Sbostic.\" Copyright (c) 1993 The Regents of the University of California. 258450Sbostic.\" All rights reserved. 358450Sbostic.\" 458450Sbostic.\" %sccs.include.redist.roff% 558450Sbostic.\" 6*58738Sbostic.\" @(#)err.3 5.2 (Berkeley) 03/19/93 758450Sbostic.\" 858450Sbostic.Dd "" 958450Sbostic.Dt ERR 3 1058450Sbostic.Os BSD 4 1158450Sbostic.Sh NAME 1258450Sbostic.Nm err , 1358450Sbostic.Nm verr , 1458450Sbostic.Nm errx , 1558450Sbostic.Nm verrx , 1658450Sbostic.Nm warn , 1758450Sbostic.Nm vwarn , 1858450Sbostic.Nm warnx , 1958450Sbostic.Nm vwarnx 2058450Sbostic.Nd formatted error messages 2158450Sbostic.Sh SYNOPSIS 2258450Sbostic.Fd #include <err.h> 2358450Sbostic.Ft void 2458450Sbostic.Fn err "int eval" "const char *fmt" "..." 2558450Sbostic.Ft void 2658450Sbostic.Fn verr "int eval" "const char *fmt" "va_list args" 2758450Sbostic.Ft void 2858450Sbostic.Fn errx "int eval" "const char *fmt" "..." 2958450Sbostic.Ft void 3058450Sbostic.Fn verrx "int eval" "const char *fmt" "va_list args" 3158450Sbostic.Ft void 3258450Sbostic.Fn warn "const char *fmt" "..." 3358450Sbostic.Ft void 3458450Sbostic.Fn vwarn "const char *fmt" "va_list args" 3558450Sbostic.Ft void 3658450Sbostic.Fn warnx "const char *fmt" "..." 3758450Sbostic.Ft void 3858450Sbostic.Fn vwarnx "const char *fmt" "va_list args" 3958450Sbostic.Sh DESCRIPTION 4058450SbosticThe 4158450Sbostic.Fn err 4258450Sbosticand 4358450Sbostic.Fn warn 4458450Sbosticfamily of functions display a formatted error message on the standard 4558450Sbosticerror output. 46*58738SbosticIn all cases, the last component of the program name, a colon character, 47*58738Sbosticand a space are output. 48*58738SbosticIf the 49*58738Sbostic.Va fmt 50*58738Sbosticargument is not NULL, the formatted error message, a colon character, 51*58738Sbosticand a space are output. 5258450SbosticIn the case of the 5358450Sbostic.Fn err , 5458450Sbostic.Fn verr , 5558450Sbostic.Fn warn , 5658450Sbosticand 5758450Sbostic.Fn vwarn 58*58738Sbosticfunctions, the error message string affiliated with the current value of 59*58738Sbosticthe global variable 6058450Sbostic.Va errno 61*58738Sbosticis output. 62*58738SbosticIn all cases, the output is followed by a newline character. 6358450Sbostic.Pp 6458450SbosticThe 6558450Sbostic.Fn err , 6658450Sbostic.Fn verr , 6758450Sbostic.Fn errx , 6858450Sbosticand 6958450Sbostic.Fn verrx 7058450Sbosticfunctions do not return, but exit with the value of the argument 7158450Sbostic.Fa eval . 7258450Sbostic.Sh EXAMPLES 7358450SbosticDisplay the current errno information string and exit: 7458450Sbostic.Bd -literal -offset indent 75*58738Sbosticif ((p = malloc(size)) == NULL) 76*58738Sbostic err(1, NULL); 7758450Sbosticif ((fd = open(file_name, O_RDONLY, 0)) == -1) 7858450Sbostic err(1, "%s", file_name); 7958450Sbostic.Ed 8058450Sbostic.Pp 8158450SbosticDisplay an error message and exit: 8258450Sbostic.Bd -literal -offset indent 8358450Sbosticif (tm.tm_hour < START_TIME) 8458450Sbostic errx(1, "too early, wait until %s", start_time_string); 8558450Sbostic.Ed 8658450Sbostic.Pp 8758450SbosticWarn of an error: 8858450Sbostic.Bd -literal -offset indent 8958450Sbosticif ((fd = open(raw_device, O_RDONLY, 0)) == -1) 9058450Sbostic warnx("%s: %s: trying the block device", 9158450Sbostic raw_device, strerror(errno)); 9258450Sbosticif ((fd = open(block_device, O_RDONLY, 0)) == -1) 9358450Sbostic err(1, "%s", block_device); 9458450Sbostic.Ed 9558450Sbostic.Sh SEE ALSO 9658450Sbostic.Xr strerror 3 9758450Sbostic.Sh HISTORY 9858450SbosticThe 9958450Sbostic.Fn err 10058450Sbosticand 10158450Sbostic.Fn warn 10258450Sbosticfunctions are 10358450Sbostic.Ud . 104