.\" Copyright (c) 1993 The Regents of the University of California. .\" All rights reserved. .\" .\" %sccs.include.redist.roff% .\" .\" @(#)err.3 5.3 (Berkeley) 06/09/93 .\" .Dd "" .Dt ERR 3 .Os BSD 4 .Sh NAME .Nm err , .Nm verr , .Nm errx , .Nm verrx , .Nm warn , .Nm vwarn , .Nm warnx , .Nm vwarnx .Nd formatted error messages .Sh SYNOPSIS .Fd #include .Ft void .Fn err "int eval" "const char *fmt" "..." .Ft void .Fn verr "int eval" "const char *fmt" "va_list args" .Ft void .Fn errx "int eval" "const char *fmt" "..." .Ft void .Fn verrx "int eval" "const char *fmt" "va_list args" .Ft void .Fn warn "const char *fmt" "..." .Ft void .Fn vwarn "const char *fmt" "va_list args" .Ft void .Fn warnx "const char *fmt" "..." .Ft void .Fn vwarnx "const char *fmt" "va_list args" .Sh DESCRIPTION The .Fn err and .Fn warn family of functions display a formatted error message on the standard error output. In all cases, the last component of the program name, a colon character, and a space are output. If the .Va fmt argument is not NULL, the formatted error message, a colon character, and a space are output. In the case of the .Fn err , .Fn verr , .Fn warn , and .Fn vwarn functions, the error message string affiliated with the current value of the global variable .Va errno is output. In all cases, the output is followed by a newline character. .Pp The .Fn err , .Fn verr , .Fn errx , and .Fn verrx functions do not return, but exit with the value of the argument .Fa eval . .Sh EXAMPLES Display the current errno information string and exit: .Bd -literal -offset indent if ((p = malloc(size)) == NULL) err(1, NULL); if ((fd = open(file_name, O_RDONLY, 0)) == -1) err(1, "%s", file_name); .Ed .Pp Display an error message and exit: .Bd -literal -offset indent if (tm.tm_hour < START_TIME) errx(1, "too early, wait until %s", start_time_string); .Ed .Pp Warn of an error: .Bd -literal -offset indent if ((fd = open(raw_device, O_RDONLY, 0)) == -1) warnx("%s: %s: trying the block device", raw_device, strerror(errno)); if ((fd = open(block_device, O_RDONLY, 0)) == -1) err(1, "%s", block_device); .Ed .Sh SEE ALSO .Xr strerror 3 .Sh HISTORY The .Fn err and .Fn warn functions first appeared in 4.4BSD.