.\" Copyright (c) 1993 The Regents of the University of California. .\" All rights reserved. .\" .\" %sccs.include.redist.roff% .\" .\" @(#)err.3 5.1 (Berkeley) 03/04/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 error message is preceded by the last component of the program name, a colon character, and a space. In the case of the .Fn err , .Fn verr , .Fn warn , and .Fn vwarn functions, a colon character, a space and the error message string affiliated with the current value of the global variable .Va errno are displayed after the formatted error message. In all cases, the message 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 ((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 are .Ud .