[Openvas-commits] r5666 - in trunk/openvas-manager: . src

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


Author: jan
Date: 2009-10-21 20:56:47 +0200 (Wed, 21 Oct 2009)
New Revision: 5666

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



Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-10-21 18:55:22 UTC (rev 5665)
+++ trunk/openvas-manager/ChangeLog	2009-10-21 18:56:47 UTC (rev 5666)
@@ -1,3 +1,7 @@
+2009-10-21  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
+	* src/openvasmd.c (cleanup, main): Factored out pidfile management.
+
 2009-10-21  Matthew Mundell <matthew.mundell at intevation.de>
 
 	Add database migration from version 1 to 2.

Modified: trunk/openvas-manager/src/openvasmd.c
===================================================================
--- trunk/openvas-manager/src/openvasmd.c	2009-10-21 18:55:22 UTC (rev 5665)
+++ trunk/openvas-manager/src/openvasmd.c	2009-10-21 18:56:47 UTC (rev 5666)
@@ -103,6 +103,7 @@
 
 #include <openvas_logging.h>
 #include <openvas_server.h>
+#include <openvas/base/pidfile.h>
 
 #include "logf.h"
 #include "manage.h"
@@ -456,13 +457,9 @@
 #endif /* LOG */
   tracef ("   Exiting.\n");
   if (log_config) free_log_configuration (log_config);
+
   /* Delete pidfile if this process is the parent. */
-  if (is_parent == 1)
-    {
-      gchar *pidfile_name = g_strdup (OPENVAS_PID_DIR "/openvasmd.pid");
-      g_unlink (pidfile_name);
-      g_free (pidfile_name);
-    }
+  if (is_parent == 1) pidfile_remove("openvasmd");
 }
 
 /**
@@ -989,23 +986,8 @@
     }
 
   /* Set our pidfile. */
+  if (pidfile_create("openvasmd")) exit (EXIT_FAILURE);
 
-  gchar *pidfile_name = g_strdup (OPENVAS_PID_DIR "/openvasmd.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