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

ATTRIBUTES

47       For   an   explanation   of   the  terms  used  in  this  section,  see
48       attributes(7).
49
50       ┌──────────────────┬───────────────┬────────────────┐
51Interface         Attribute     Value          
52       ├──────────────────┼───────────────┼────────────────┤
53err(), errx(),    │ Thread safety │ MT-Safe locale │
54warn(), warnx(),  │               │                │
55verr(), verrx(),  │               │                │
56vwarn(), vwarnx() │               │                │
57       └──────────────────┴───────────────┴────────────────┘
58

CONFORMING TO

60       These functions are nonstandard BSD extensions.
61

EXAMPLE

63       Display the current errno information string and exit:
64
65           p = malloc(size);
66           if (p == NULL)
67               err(1, NULL);
68           fd = open(file_name, O_RDONLY, 0);
69           if (fd == -1)
70               err(1, "%s", file_name);
71
72       Display an error message and exit:
73
74           if (tm.tm_hour < START_TIME)
75               errx(1, "too early, wait until %s", start_time_string);
76
77       Warn of an error:
78
79           fd = open(raw_device, O_RDONLY, 0);
80           if (fd == -1)
81               warnx("%s: %s: trying the block device",
82                       raw_device, strerror(errno));
83           fd = open(block_device, O_RDONLY, 0);
84           if (fd == -1)
85               err(1, "%s", block_device);
86

SEE ALSO

88       error(3), exit(3), perror(3), printf(3), strerror(3)
89

COLOPHON

91       This page is part of release 4.15 of the Linux  man-pages  project.   A
92       description  of  the project, information about reporting bugs, and the
93       latest    version    of    this    page,    can     be     found     at
94       https://www.kernel.org/doc/man-pages/.
95
96
97
98Linux                             2017-09-15                            ERR(3)
Impressum