diff -up bind-9.8.2rc1/bin/dig/nslookup.c.rh816164 bind-9.8.2rc1/bin/dig/nslookup.c --- bind-9.8.2rc1/bin/dig/nslookup.c.rh816164 2012-05-07 17:01:49.054026716 +0200 +++ bind-9.8.2rc1/bin/dig/nslookup.c 2012-05-07 17:15:42.516105665 +0200 @@ -56,6 +56,7 @@ static isc_boolean_t in_use = ISC_FALSE; static char defclass[MXRD] = "IN"; static char deftype[MXRD] = "A"; static isc_event_t *global_event = NULL; +static int seen_error = -1; static char domainopt[DNS_NAME_MAXTEXT]; @@ -404,6 +405,14 @@ trying(char *frm, dig_lookup_t *lookup) isc_result_t printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { char servtext[ISC_SOCKADDR_FORMATSIZE]; + int force_error; + + /* + * We get called multiple times. + * Preserve any existing error status. + */ + force_error = (seen_error == 1) ? 1 : 0; + seen_error = 1; debug("printmessage()"); @@ -451,6 +460,7 @@ printmessage(dig_query_t *query, dns_mes printsection(query, msg, headers, DNS_SECTION_ADDITIONAL); } + seen_error = force_error; return (ISC_R_SUCCESS); } @@ -888,5 +898,5 @@ main(int argc, char **argv) { destroy_libs(); isc_app_finish(); - return (0); + return (seen_error == 0) ? 0 : 1; }