[Openvas-commits] r5676 - in trunk/gsa: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 22 22:13:25 CEST 2009


Author: jan
Date: 2009-10-22 22:13:23 +0200 (Thu, 22 Oct 2009)
New Revision: 5676

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
Log:
* src/gsad.c (gsad_cleanup, main): Factored out pidfile management.



Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-10-22 13:43:41 UTC (rev 5675)
+++ trunk/gsa/ChangeLog	2009-10-22 20:13:23 UTC (rev 5676)
@@ -1,3 +1,7 @@
+2009-10-22  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
+	* src/gsad.c (gsad_cleanup, main): Factored out pidfile management.
+
 2009-10-20  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
 
 	* src/gsad.c (request_handler): New.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-10-22 13:43:41 UTC (rev 5675)
+++ trunk/gsa/src/gsad.c	2009-10-22 20:13:23 UTC (rev 5676)
@@ -41,6 +41,8 @@
 #undef G_LOG_FATAL_MASK
 #define G_LOG_FATAL_MASK G_LOG_LEVEL_ERROR
 
+#include <openvas/base/pidfile.h>
+
 /**
  * @brief HTTP request handler for GSAD.
  *
@@ -362,10 +364,7 @@
 
   if (log_config) free_log_configuration (log_config);
 
-  /* Delete pidfile. */
-  char *pidfile_name = strdup (GSAD_PID_DIR "/gsad.pid");
-  unlink (pidfile_name);
-  free (pidfile_name);
+  pidfile_remove("gsad");
 }
 
 /**
@@ -621,21 +620,8 @@
     }
   else
     {
-      char *pidfile_name = strdup (GSAD_PID_DIR "/gsad.pid");
-      FILE *pidfile = fopen (pidfile_name, "w"); /* flawfinder: ignore, this
-        file is opened for writing, therefore
-        no special file type is opened (the file is newly created) */
-      if (pidfile == NULL)
-        {
-          g_critical ("%s: Unable to write pidfile!\n", __FUNCTION__);
-          exit (EXIT_FAILURE);
-        }
-      else
-        {
-          fprintf (pidfile, "%d\n", getpid ());
-          fclose (pidfile);
-          free (pidfile_name);
-        }
+      if (pidfile_create("gsad")) exit (EXIT_FAILURE);
+
       tracef ("GSAD started successfully and is listening on port %d.\n",
               gsad_port);
     }



More information about the Openvas-commits mailing list