[Openvas-commits] r5667 - in trunk/openvas-administrator: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Oct 21 20:57:45 CEST 2009


Author: jan
Date: 2009-10-21 20:57:45 +0200 (Wed, 21 Oct 2009)
New Revision: 5667

Modified:
   trunk/openvas-administrator/ChangeLog
   trunk/openvas-administrator/src/openvasad.c
Log:
* src/openvasad.c (cleanup, main): Factored out pidfile management.



Modified: trunk/openvas-administrator/ChangeLog
===================================================================
--- trunk/openvas-administrator/ChangeLog	2009-10-21 18:56:47 UTC (rev 5666)
+++ trunk/openvas-administrator/ChangeLog	2009-10-21 18:57:45 UTC (rev 5667)
@@ -1,3 +1,7 @@
+2009-10-21  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
+	* src/openvasad.c (cleanup, main): Factored out pidfile management.
+
 2009-09-29  Matthew Mundell <matthew.mundell at intevation.de>
 
 	* src/oad.c (oap_xml_handle_start_element): Correct command name in

Modified: trunk/openvas-administrator/src/openvasad.c
===================================================================
--- trunk/openvas-administrator/src/openvasad.c	2009-10-21 18:56:47 UTC (rev 5666)
+++ trunk/openvas-administrator/src/openvasad.c	2009-10-21 18:57:45 UTC (rev 5667)
@@ -64,6 +64,7 @@
 #include <openvas_logging.h>
 #include <openvas_server.h>
 #include <openvas_auth.h>
+#include <openvas/base/pidfile.h>
 
 /**
  * @brief The name of this program.
@@ -334,10 +335,7 @@
 #endif
   tracef ("   Exiting.\n");
   if (log_config) free_log_configuration (log_config);
-  /* Delete pidfile. */
-  gchar *pidfile_name = g_strdup (OPENVAS_PID_DIR "/openvasad.pid");
-  g_unlink (pidfile_name);
-  g_free (pidfile_name);
+  pidfile_remove("openvasad");
 }
 
 /**
@@ -878,23 +876,8 @@
     }
 
   /* Set our pidfile. */
+  if (pidfile_create("openvasad")) exit (EXIT_FAILURE);
 
-  gchar *pidfile_name = g_strdup (OPENVAS_PID_DIR "/openvasad.pid");
-  FILE *pidfile = g_fopen (pidfile_name, "w");
-  if (pidfile == NULL)
-    {
-      g_critical ("%s: failed to open pidfile: %s\n",
-                  __FUNCTION__,
-                  strerror (errno));
-      exit (EXIT_FAILURE);
-    }
-  else
-    {
-      g_fprintf (pidfile, "%d\n", getpid());
-      fclose (pidfile);
-      g_free (pidfile_name);
-    }
-
   /* Loop waiting for connections and passing the work to
    * `accept_and_maybe_fork'.
    *



More information about the Openvas-commits mailing list