In example use of err(3) and errx(3), use sysexits(3) constants.
MFC after: 3 days Submitted by: Bruce Cran <bruce at cran dot org dot uk>
This commit is contained in:
parent
1a0edb10ca
commit
46658b2b2e
@ -178,15 +178,16 @@ or a null pointer
|
|||||||
Display the current errno information string and exit:
|
Display the current errno information string and exit:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
if ((p = malloc(size)) == NULL)
|
if ((p = malloc(size)) == NULL)
|
||||||
err(1, NULL);
|
err(EX_OSERR, NULL);
|
||||||
if ((fd = open(file_name, O_RDONLY, 0)) == -1)
|
if ((fd = open(file_name, O_RDONLY, 0)) == -1)
|
||||||
err(1, "%s", file_name);
|
err(EX_NOINPUT, "%s", file_name);
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Display an error message and exit:
|
Display an error message and exit:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
if (tm.tm_hour < START_TIME)
|
if (tm.tm_hour < START_TIME)
|
||||||
errx(1, "too early, wait until %s", start_time_string);
|
errx(EX_DATAERR, "too early, wait until %s",
|
||||||
|
start_time_string);
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Warn of an error:
|
Warn of an error:
|
||||||
@ -195,7 +196,7 @@ if ((fd = open(raw_device, O_RDONLY, 0)) == -1)
|
|||||||
warnx("%s: %s: trying the block device",
|
warnx("%s: %s: trying the block device",
|
||||||
raw_device, strerror(errno));
|
raw_device, strerror(errno));
|
||||||
if ((fd = open(block_device, O_RDONLY, 0)) == -1)
|
if ((fd = open(block_device, O_RDONLY, 0)) == -1)
|
||||||
err(1, "%s", block_device);
|
err(EX_OSFILE, "%s", block_device);
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Warn of an error without using the global variable
|
Warn of an error without using the global variable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user