[Pacemaker] [PATCH 9/8 ] errata, only close file descriptors if that had been opened

Bernd Schubert bernd.schubert at fastmail.fm
Thu Sep 16 10:58:34 UTC 2010


cl_log: Only close file descriptors if that had been opened

This patch also could be merged with the 6th patch in the series
(restore old open/write/close semantics). It fixes a valgrind
warning about invalid close().


Signed-off-by: Bernd Schubert <bschubert at ddn.com>


diff --git a/lib/clplumbing/cl_log.c b/lib/clplumbing/cl_log.c
--- a/lib/clplumbing/cl_log.c
+++ b/lib/clplumbing/cl_log.c
@@ -640,8 +640,10 @@ cl_direct_log(int priority, const char* 
 	 * program needs a signal handler. Therefore we close fd's, if the 
 	 * caller did not tell us it has the signal handler */
 	if (have_signal_handler == FALSE) {
-		close(debug_fd);
-		close(log_fd);
+		if (debug_fd >= 0)
+			close(debug_fd);
+		if (log_fd >=0 )
+			close(log_fd);
 		debug_fd = -1;
 		log_fd = -1;
 	}




More information about the Pacemaker mailing list