NAME
eerrrr, vveerrrr, eerrrrcc, vveerrrrcc, eerrrrxx, vveerrrrxx, wwaarrnn, vvwwaarrnn, wwaarrnncc, vvwwaarrnncc, wwaarrnnxx,
vvwwaarrnnxx, eerrrrsseetteexxiitt, eerrrrsseettffiillee - formatted error messages
LLIIBBRRAARRYYStandard C Library (libc, -lc)
SYNOPSIS
##iinncclluuddee <
void> eerrrr(int eval, const char *fmt, ...);
voideerrrrsseetteexxiitt(void (*exitf)(int));
voideerrrrsseettffiillee(void *vfp);
voideerrrrcc(int eval, int code, const char *fmt, ...);
voideerrrrxx(int eval, const char *fmt, ...);
void wwaarrnn(const char *fmt, ...); void wwaarrnncc(int code, const char *fmt, ...); void wwaarrnnxx(const char *fmt, ...);##iinncclluuddee <
void> vveerrrr(int eval, const char *fmt, valist args);
voidvveerrrrcc(int eval, int code, const char *fmt, valist args);
voidvveerrrrxx(int eval, const char *fmt, valist args);
void vvwwaarrnn(const char *fmt, valist args); void vvwwaarrnncc(int code, const char *fmt, valist args); void vvwwaarrnnxx(const char *fmt, valist args);DESCRIPTION
The eerrrr() and wwaarrnn() family of functions display a formatted error mes-
sage on the standard error output, or on another file specified using the
eerrrrsseettffiillee() function. In all cases, the last component of the program
name, a colon character, and a space are output. If the fmt argument isnot NULL, the printf(3) -like formatted error message is output. The
output is terminated by a newline character.The eerrrr(), eerrrrcc(), vveerrrr(), vveerrrrcc(), wwaarrnn(), wwaarrnncc(), vvwwaarrnn(), and
vvwwaarrnncc() functions append an error message obtained from strerror(3)
based on a code or the global variable errno, preceded by another colon
and space unless the fmt argument is NULL.In the case of the eerrrrcc(), vveerrrrcc(), wwaarrnncc(), and vvwwaarrnncc() functions, the
code argument is used to look up the error message.
The eerrrr(), vveerrrr(), wwaarrnn(), and vvwwaarrnn() functions use the global variable
errno to look up the error message.
The eerrrrxx() and wwaarrnnxx() functions do not append an error message.
The eerrrr(), vveerrrr(), eerrrrcc(), vveerrrrcc(), eerrrrxx(), and vveerrrrxx() functions do not
return, but exit with the value of the argument eval. It is recommended that the standard values defined in sysexits(3) be used for the value ofeval. The eerrrrsseetteexxiitt() function can be used to specify a function
which is called before exit(3) to perform any necessary cleanup; passing a null function pointer for exitf resets the hook to do nothing. Theeerrrrsseettffiillee() function sets the output stream used by the other func-
tions. Its vfp argument must be either a pointer to an open stream (pos-
sibly already converted to void *) or a null pointer (in which case theoutput stream is set to standard error).
EEXXAAMMPPLLEESSDisplay the current errno information string and exit:
if ((p = malloc(size)) == NULL)err(1, NULL);
if ((fd = open(filename, ORDONLY, 0)) == -1)
err(1, "%s", filename);
Display an error message and exit:
if (tm.tmhour < STARTTIME)errx(1, "too early, wait until %s", starttimestring);
Warn of an error:
if ((fd = open(rawdevice, ORDONLY, 0)) == -1)
warnx("%s: %s: trying the block device",
rawdevice, strerror(errno));
if ((fd = open(blockdevice, ORDONLY, 0)) == -1)
err(1, "%s", blockdevice);
Warn of an error without using the global variable errno:
error = myfunction(); /* returns a value from
*/ if (error != 0)
warnc(error, "myfunction");
SEE ALSO
exit(3), fmtmsg(3), printf(3), strerror(3), sysexits(3)
HISTORYThe eerrrr() and wwaarrnn() functions first appeared in 4.4BSD. The
eerrrrsseetteexxiitt() and eerrrrsseettffiillee() functions first appeared in
FreeBSD 2.1. The eerrrrcc() and wwaarrnncc() functions first appeared in
FreeBSD 3.0. BSD March 6, 1999 BSD