[PATCH] Set but unused wait_result var on checks.c

Ricardo Maraschini ricardo.maraschini at opservices.com.br
Fri Jun 22 18:47:29 CEST 2012


Hi,

Accordingly to manpages, waitpid is expected to return -1 on error. As run_async_host_check_3x() and run_async_service_check() already return an ERROR when a problem during fork occurs, i believe it's appropriate to return an ERROR when we are unable to wait for child pid as well.

This patch address some "set but not used [-Wunused-but-set-variable]" warning during nagios compilation.

OK? Comments?





--- base/checks.c	(revision 1973)
+++ base/checks.c	(working copy)
@@ -878,6 +878,9 @@
 		/* don't do this if large install tweaks are enabled - we'll clean up children in event loop */
 		if(child_processes_fork_twice == TRUE)
 			wait_result = waitpid(pid, NULL, 0);
+			if(wait_result == -1) {
+				return ERROR;
+			}
 		}
 
 	/* see if we were able to run the check... */
@@ -3264,6 +3267,9 @@
 		/* if large install tweaks are enabled, we'll clean up the zombie process later */
 		if(child_processes_fork_twice == TRUE)
 			wait_result = waitpid(pid, NULL, 0);
+			if(wait_result == -1) {
+				return ERROR;
+			}
 		}
 
 	/* see if we were able to run the check... */

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/




More information about the Developers mailing list