lib: Make error.c more like error(3)
authorColin Cross <ccross@google.com>
Fri, 10 Sep 2021 18:07:16 +0000 (11:07 -0700)
committerMark Wielaard <mark@klomp.org>
Sun, 12 Sep 2021 20:43:17 +0000 (22:43 +0200)
commit7582a0d3e09ee154961bbba9285a224e5d09f407
treed7751e25ad46dd3f61f841442e6d7cabff237014
parent52b0d9caf5575a62322c9fbe920b69444dd09162
lib: Make error.c more like error(3)

Fix some issues with the error reimplementation to make it match
the specification for error(3).

Flush stdout before printing to stderr.  Also flush stderr afterwards,
which is not specified in the man page for error(3), but is what
bionic does.

error(3) prints strerror(errnum) if and only if errnum is nonzero,
but verr prints strerror(errno) unconditionaly.  When errnum is nonzero
copy it to errno and use verr, and when it is not set use verrx that
doesn't print errno.

error(3) only exits if status is nonzero, but verr exits uncondtionally.
Use vwarn/vwarnx when status is zero, which don't exit.

Signed-off-by: Colin Cross <ccross@google.com>
lib/ChangeLog
lib/error.c