aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-10-10 14:12:28 -0700
committerRob Landley <rob@landley.net>2019-10-12 17:15:54 -0500
commit7adff6b2cad30de073fb597cd0d10826067965ad (patch)
tree9059cb9d619f6f835bc36f48ae622b7c82b652bf
parentc8400d7f82adbf1716244e136121ab59a4b075fb (diff)
downloadtoybox-7adff6b2cad30de073fb597cd0d10826067965ad.tar.gz
hostname: fix error reporting.
The <netdb.h> functions have their own errno :-(
-rw-r--r--toys/lsb/hostname.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/toys/lsb/hostname.c b/toys/lsb/hostname.c
index b3cc1967..daa60cc0 100644
--- a/toys/lsb/hostname.c
+++ b/toys/lsb/hostname.c
@@ -61,7 +61,8 @@ void hostname_main(void)
// We only do the DNS lookup for -d and -f.
if (FLAG(d) || FLAG(f)) {
- if (!(h = gethostbyname(toybuf))) perror_exit("gethostbyname");
+ if (!(h = gethostbyname(toybuf)))
+ error_exit("gethostbyname: %s", hstrerror(h_errno));
snprintf(toybuf, sizeof(toybuf), "%s", h->h_name);
}
dot = toybuf+strcspn(toybuf, ".");