1ERR(3)                     Linux Programmer's Manual                    ERR(3)
2
3
4

NAME

6       err,  verr,  errx,  verrx, warn, vwarn, warnx, vwarnx - formatted error
7       messages
8

SYNOPSIS

10       #include <err.h>
11
12       void err(int eval, const char *fmt, ...);
13
14       void errx(int eval, const char *fmt, ...);
15
16       void warn(const char *fmt, ...);
17
18       void warnx(const char *fmt, ...);
19
20       #include <stdarg.h>
21
22       void verr(int eval, const char *fmt, va_list args);
23
24       void verrx(int eval, const char *fmt, va_list args);
25
26       void vwarn(const char *fmt, va_list args);
27
28       void vwarnx(const char *fmt, va_list args);
29

DESCRIPTION

31       The err() and warn() family of functions display a formatted error mes‐
32       sage on the standard error output.  In all cases, the last component of
33       the program name, a colon character, and a space are  output.   If  the
34       fmt argument is not NULL, the printf(3)-like formatted error message is
35       output.  The output is terminated by a newline character.
36
37       The err(), verr(), warn(), and vwarn() functions append an  error  mes‐
38       sage  obtained  from strerror(3) based on a code or the global variable
39       errno, preceded by another colon and space unless the fmt  argument  is
40       NULL.
41
42       The  err(),  verr(), warn(), and vwarn() functions use the global vari‐
43       able errno to look up the error message.
44
45       The errx() and warnx() functions do not append an error message.
46
47       The err(), verr(), errx(), and verrx() functions  do  not  return,  but
48       exit with the value of the argument eval.
49

EXAMPLES

51       Display the current errno information string and exit:
52
53           if ((p = malloc(size)) == NULL)
54               err(1, NULL);
55           if ((fd = open(file_name, O_RDONLY, 0)) == -1)
56               err(1, "%s", file_name);
57
58       Display an error message and exit:
59
60           if (tm.tm_hour < START_TIME)
61               errx(1, "too early, wait until %s", start_time_string);
62
63       Warn of an error:
64
65           if ((fd = open(raw_device, O_RDONLY, 0)) == -1)
66               warnx("%s: %s: trying the block device",
67                       raw_device, strerror(errno));
68           if ((fd = open(block_device, O_RDONLY, 0)) == -1)
69               err(1, "%s", block_device);
70

CONFORMING TO

72       These functions are non-standard BSD extensions.
73

SEE ALSO

75       error(3), exit(3), perror(3), printf(3), strerror(3)
76

COLOPHON

78       This  page  is  part of release 3.22 of the Linux man-pages project.  A
79       description of the project, and information about reporting  bugs,  can
80       be found at http://www.kernel.org/doc/man-pages/.
81
82
83
84Linux                             2007-12-28                            ERR(3)
Impressum