1ERR(3)                     Library Functions Manual                     ERR(3)
2
3
4

NAME

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

SYNOPSIS

10       void
11       err(eval, fmt, ...)
12           int eval;
13           char *fmt;
14
15       void
16       verr(eval, fmt, args)
17           int eval;
18           char *fmt;
19           va_list args;
20
21       void
22       errx(eval, fmt, ...)
23           int eval;
24           char *fmt;
25
26       void
27       verrx(eval, fmt, args)
28           int eval
29           char *fmt;
30           va_list args;
31
32       void
33       warn(fmt, ...)
34           char *fmt;
35
36       void
37       vwarn(fmt, args)
38           char *fmt;
39           va_list args;
40
41       void
42       warnx(fmt, ...)
43           char *fmt;
44
45       void
46       vwarnx(fmt, args)
47           char *fmt;
48           va_list args;
49

DESCRIPTION

51       The err and warn family of functions display a formatted error  message
52       on  the standard error output.  In all cases, the last component of the
53       program name, a colon character, and a space are output.   If  the  fmt
54       argument  is  not NULL, the formatted error message, a colon character,
55       and a space are output.  In the case of the err, verr, warn, and  vwarn
56       functions,  the  error message string affiliated with the current value
57       of the global variable errno is output.  In all cases,  the  output  is
58       followed by a newline character.
59
60       The  err,  verr, errx, and verrx functions do not return, but exit with
61       the value of the argument eval.
62

EXAMPLES

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

SEE ALSO

85       strerror(3)
86

HISTORY

88       The err and warn functions first appeared in 4.4BSD.
89
90
91
924th Berkeley Distribution      February 3, 1995                         ERR(3)
Impressum