1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)err.3 8.1 (Berkeley) 06/09/93 7.\" 8.Dd "" 9.Dt ERR 3 10.Os BSD 4 11.Sh NAME 12.Nm err , 13.Nm verr , 14.Nm errx , 15.Nm verrx , 16.Nm warn , 17.Nm vwarn , 18.Nm warnx , 19.Nm vwarnx 20.Nd formatted error messages 21.Sh SYNOPSIS 22.Fd #include <err.h> 23.Ft void 24.Fn err "int eval" "const char *fmt" "..." 25.Ft void 26.Fn verr "int eval" "const char *fmt" "va_list args" 27.Ft void 28.Fn errx "int eval" "const char *fmt" "..." 29.Ft void 30.Fn verrx "int eval" "const char *fmt" "va_list args" 31.Ft void 32.Fn warn "const char *fmt" "..." 33.Ft void 34.Fn vwarn "const char *fmt" "va_list args" 35.Ft void 36.Fn warnx "const char *fmt" "..." 37.Ft void 38.Fn vwarnx "const char *fmt" "va_list args" 39.Sh DESCRIPTION 40The 41.Fn err 42and 43.Fn warn 44family of functions display a formatted error message on the standard 45error output. 46In all cases, the last component of the program name, a colon character, 47and a space are output. 48If the 49.Va fmt 50argument is not NULL, the formatted error message, a colon character, 51and a space are output. 52In the case of the 53.Fn err , 54.Fn verr , 55.Fn warn , 56and 57.Fn vwarn 58functions, the error message string affiliated with the current value of 59the global variable 60.Va errno 61is output. 62In all cases, the output is followed by a newline character. 63.Pp 64The 65.Fn err , 66.Fn verr , 67.Fn errx , 68and 69.Fn verrx 70functions do not return, but exit with the value of the argument 71.Fa eval . 72.Sh EXAMPLES 73Display the current errno information string and exit: 74.Bd -literal -offset indent 75if ((p = malloc(size)) == NULL) 76 err(1, NULL); 77if ((fd = open(file_name, O_RDONLY, 0)) == -1) 78 err(1, "%s", file_name); 79.Ed 80.Pp 81Display an error message and exit: 82.Bd -literal -offset indent 83if (tm.tm_hour < START_TIME) 84 errx(1, "too early, wait until %s", start_time_string); 85.Ed 86.Pp 87Warn of an error: 88.Bd -literal -offset indent 89if ((fd = open(raw_device, O_RDONLY, 0)) == -1) 90 warnx("%s: %s: trying the block device", 91 raw_device, strerror(errno)); 92if ((fd = open(block_device, O_RDONLY, 0)) == -1) 93 err(1, "%s", block_device); 94.Ed 95.Sh SEE ALSO 96.Xr strerror 3 97.Sh HISTORY 98The 99.Fn err 100and 101.Fn warn 102functions first appeared in 4.4BSD. 103