[icinga-checkins] icinga.org: icinga-core/master: minor cleanups to cgiutils.c ( Eric Sesterhenn)

git at icinga.org git at icinga.org
Wed May 19 13:41:50 CEST 2010


Module: icinga-core
Branch: master
Commit: b8de14a3f0c6931ccb5c357fd285628854b7d2a5
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=b8de14a3f0c6931ccb5c357fd285628854b7d2a5

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed May  5 16:07:31 2010 +0200

minor cleanups to cgiutils.c (Eric Sesterhenn)

fixes #386

---

 Changelog      |    1 +
 cgi/cgiutils.c |   13 +++++--------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Changelog b/Changelog
index 4d136c2..5292633 100644
--- a/Changelog
+++ b/Changelog
@@ -17,6 +17,7 @@ FIXES
 * core: fix for choosing next valid time on day of DST change when clocks go one hour backwards (Ton Voon)
 * core: fix for nagios now erroring when "Error: Could not find any contactgroup matching..." displayed (Ton Voon)
 * core: minor cleanups to icingastats.c (Eric Sesterhenn)
+* core: minor cleanups to cgiutils.c (Eric Sestersenn)
 
 * idoutils: Host DB inserts use string 'NULL\n' instead of NULL (William Preston)
 * idoutils: ndo2db_get_object_id fails to return existing IDs (William Preston)
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 16fef9a..e486b30 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -2291,9 +2291,7 @@ int check_daemon_running(void) {
 	char *proc_file=NULL;
 	char *input = NULL;
 	char *val = NULL;
-	char *daemon_name = NULL;
-	struct stat statbuf;
-	int pid, testpid, found;
+	int pid, testpid;
 	char input_buffer[CHARLEN];
 	mmapfile *fk;
 	FILE *fp;
@@ -2306,9 +2304,7 @@ int check_daemon_running(void) {
 	if((fk=mmap_fopen(lock_file))==NULL) {
 
 		/* no lock file found try program name instead */
-                asprintf(&daemon_name,"%s",PROGRAM_NAME_LC);
-
-                if(asprintf(&proc_file,"/bin/ps -o pid -C %s",daemon_name)==-1) {
+                if(asprintf(&proc_file,"/bin/ps -o pid -C %s",PROGRAM_NAME_LC)==-1) {
                         free(proc_file);
                         return ERROR;
                 }
@@ -2321,13 +2317,14 @@ int check_daemon_running(void) {
                 fgets(input_buffer,CHARLEN-1,fp);
                 fgets(input_buffer,CHARLEN-1,fp);
 
+		pclose(fp);
+		free(proc_file);
+
                 /* check if entry found */
                 if (sscanf(input_buffer,"%d",&testpid)!=1) {
-                        free(proc_file);
                         return ERROR;
                 } else {
 			/* daemon is running */
-			free(proc_file);
 			return OK;
 		}
 	}





More information about the icinga-checkins mailing list