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 the global variable errno, pre‐
39       ceded by another colon and space unless the fmt argument is NULL.
40
41       The errx() and warnx() functions do not append an error message.
42
43       The err(), verr(), errx(), and verrx() functions  do  not  return,  but
44       exit with the value of the argument eval.
45

CONFORMING TO

47       These functions are nonstandard BSD extensions.
48

EXAMPLE

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

SEE ALSO

71       error(3), exit(3), perror(3), printf(3), strerror(3)
72

COLOPHON

74       This  page  is  part of release 3.53 of the Linux man-pages project.  A
75       description of the project, and information about reporting  bugs,  can
76       be found at http://www.kernel.org/doc/man-pages/.
77
78
79
80Linux                             2012-03-15                            ERR(3)
Impressum