[Openvas-commits] r5668 - in trunk/openvas-scanner: . openvassd

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


Author: jan
Date: 2009-10-21 20:58:55 +0200 (Wed, 21 Oct 2009)
New Revision: 5668

Modified:
   trunk/openvas-scanner/ChangeLog
   trunk/openvas-scanner/openvassd/openvassd.c
   trunk/openvas-scanner/openvassd/sighand.c
   trunk/openvas-scanner/openvassd/utils.c
   trunk/openvas-scanner/openvassd/utils.h
Log:
* openvassd/openvassd.c (restart_openvassd, main): Use new
pidfile management.

* openvassd/sighand.c (sighandler): Use new pidfile management.

* openvassd/utils.c (create_pid_file, delete_pid_file): Removed.

* openvassd/utils.h: Removed protos accordingly.



Modified: trunk/openvas-scanner/ChangeLog
===================================================================
--- trunk/openvas-scanner/ChangeLog	2009-10-21 18:57:45 UTC (rev 5667)
+++ trunk/openvas-scanner/ChangeLog	2009-10-21 18:58:55 UTC (rev 5668)
@@ -1,3 +1,14 @@
+2009-10-21  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
+	* openvassd/openvassd.c (restart_openvassd, main): Use new
+	pidfile management.
+
+	* openvassd/sighand.c (sighandler): Use new pidfile management.
+
+	* openvassd/utils.c (create_pid_file, delete_pid_file): Removed.
+
+	* openvassd/utils.h: Removed protos accordingly.
+
 2009-10-20  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
 
 	* openvassd/comm.c: replace ntp.h by otp.h.

Modified: trunk/openvas-scanner/openvassd/openvassd.c
===================================================================
--- trunk/openvas-scanner/openvassd/openvassd.c	2009-10-21 18:57:45 UTC (rev 5667)
+++ trunk/openvas-scanner/openvassd/openvassd.c	2009-10-21 18:58:55 UTC (rev 5668)
@@ -287,7 +287,7 @@
  char fpath[1024];
 
  close(global_iana_socket);
- delete_pid_file();
+ pidfile_remove("openvassd");
  if(fork () == 0)
  {
   if(strchr(orig_argv[0], '/') != NULL )
@@ -1142,13 +1142,13 @@
       if(!fork())
         {
           setsid();
-          create_pid_file();
+          pidfile_create("openvassd");
           main_loop();
         }
     }
   else
     {
-      create_pid_file();
+      pidfile_create("openvassd");
       main_loop();
     }
   DO_EXIT(0);

Modified: trunk/openvas-scanner/openvassd/sighand.c
===================================================================
--- trunk/openvas-scanner/openvassd/sighand.c	2009-10-21 18:57:45 UTC (rev 5667)
+++ trunk/openvas-scanner/openvassd/sighand.c	2009-10-21 18:58:55 UTC (rev 5668)
@@ -45,6 +45,8 @@
 #include <sys/resource.h>
 #endif
 
+#include <openvas/base/pidfile.h>
+
 extern pid_t bpf_server_pid;
 extern pid_t nasl_server_pid;
 
@@ -165,15 +167,15 @@
   case SIGTERM:
   	sig = "TERM";
 	murderer++;
-	delete_pid_file();
+	pidfile_remove("openvassd");
   	break;
   case SIGUSR1 :
  	sig = "USR1";
-	delete_pid_file();
+	pidfile_remove("openvassd");
  	break;
   case SIGINT :
   	sig = "INT";
-	delete_pid_file();
+	pidfile_remove("openvassd");
 	murderer++;
 	break;
   case SIGSEGV :
@@ -194,14 +196,10 @@
  if(murderer)
   make_em_die(sign);
   
- 
- 
-  
  _EXIT(0);
 }
 
 
-
 void sighand_segv()
 {
 #ifdef HAVE__EXIT

Modified: trunk/openvas-scanner/openvassd/utils.c
===================================================================
--- trunk/openvas-scanner/openvassd/utils.c	2009-10-21 18:57:45 UTC (rev 5667)
+++ trunk/openvas-scanner/openvassd/utils.c	2009-10-21 18:58:55 UTC (rev 5668)
@@ -282,46 +282,6 @@
 return(ret);
 }
 
-/*-----------------------------------------------------------------
-
-		pid file management
-		
--------------------------------------------------------------------*/
-
-/** @todo use glib functions to create the path */
-void
-create_pid_file ()
-{
- FILE * f;
- char * fname = malloc(strlen(OPENVASSD_PIDDIR) + strlen("/openvassd.pid") + 1);
- strcpy(fname, OPENVASSD_PIDDIR);
- strcat(fname, "/openvassd.pid");
-
- f = fopen(fname, "w");
- if(!f)
- {
-  fprintf(stderr, "'%s'\n", fname);
-  perror("create_pid_file() : open ");
-  free(fname);
-  return;
- }
- fprintf(f, "%d\n", getpid());
- fclose(f);
- free(fname);
-}
-
-/** @todo use glib functions to create the path */
-void
-delete_pid_file ()
-{
- char * fname = malloc(strlen(OPENVASSD_PIDDIR) + strlen("/openvassd.pid") + 1);
- strcpy(fname, OPENVASSD_PIDDIR);
- strcat(fname, "/openvassd.pid");
- unlink(fname);
- free(fname);
-}
-
-
 /**
  * Returns a name suitable for a temporary file. 
  * This function ensures that this name is not taken

Modified: trunk/openvas-scanner/openvassd/utils.h
===================================================================
--- trunk/openvas-scanner/openvassd/utils.h	2009-10-21 18:57:45 UTC (rev 5667)
+++ trunk/openvas-scanner/openvassd/utils.h	2009-10-21 18:58:55 UTC (rev 5668)
@@ -57,8 +57,6 @@
 void attack_atom_remove(struct attack_atom **, char *);
 
 
-void create_pid_file();
-void delete_pid_file();
 char*temp_file_name();
 int version_check(char *, char*);
 



More information about the Openvas-commits mailing list