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