[Openvas-commits] r5548 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Oct 15 11:30:06 CEST 2009
Author: mwiegand
Date: 2009-10-15 11:30:05 +0200 (Thu, 15 Oct 2009)
New Revision: 5548
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/openvasmd.c
Log:
Make sure the parent pidfile is only removed when the parent exits.
* src/openvasmd.c: Introduce global is_parent indicator.
(accept_and_maybe_fork): Set is_parent to 0 in the child immediately
after forking.
(cleanup): Check if this process is the parent before removing the
pidfile.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2009-10-15 07:41:11 UTC (rev 5547)
+++ trunk/openvas-manager/ChangeLog 2009-10-15 09:30:05 UTC (rev 5548)
@@ -1,3 +1,13 @@
+2009-10-15 Michael Wiegand <michael.wiegand at intevation.de>
+
+ Make sure the parent pidfile is only removed when the parent exits.
+
+ * src/openvasmd.c: Introduce global is_parent indicator.
+ (accept_and_maybe_fork): Set is_parent to 0 in the child immediately
+ after forking.
+ (cleanup): Check if this process is the parent before removing the
+ pidfile.
+
2009-10-13 Matthew Mundell <matthew.mundell at intevation.de>
Add parsing of NVT category from OTP.
Modified: trunk/openvas-manager/src/openvasmd.c
===================================================================
--- trunk/openvas-manager/src/openvasmd.c 2009-10-15 07:41:11 UTC (rev 5547)
+++ trunk/openvas-manager/src/openvasmd.c 2009-10-15 09:30:05 UTC (rev 5548)
@@ -210,6 +210,11 @@
*/
static gchar *database = NULL;
+/**
+ * @brief Is this process parent or child?
+ */
+int is_parent = 1;
+
/* Forking, serving the client. */
@@ -380,6 +385,7 @@
case 0:
/* Child. */
{
+ is_parent = 0;
#endif /* FORK */
// FIX get flags first
/* The socket must have O_NONBLOCK set, in case an "asynchronous
@@ -450,10 +456,13 @@
#endif
tracef (" Exiting.\n");
if (log_config) free_log_configuration (log_config);
- /* Delete pidfile. */
- gchar *pidfile_name = g_strdup (OPENVAS_PID_DIR "/openvasmd.pid");
- g_unlink (pidfile_name);
- g_free (pidfile_name);
+ /* 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);
+ }
}
/**
More information about the Openvas-commits
mailing list