[or-cvs] Integrate new daemon code, adapted from submission by chris...

Nick Mathewson nickm at seul.org
Sat Jan 3 22:40:51 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv6366/src/or

Modified Files:
	main.c 
Log Message:
Integrate new daemon code, adapted from submission by christian grothoff

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- main.c	23 Dec 2003 07:42:01 -0000	1.160
+++ main.c	3 Jan 2004 22:40:49 -0000	1.161
@@ -396,8 +396,6 @@
 }
 
 static int init_from_config(int argc, char **argv) {
-  static int have_daemonized=0;
-
   if(getconfig(argc,argv,&options)) {
     log_fn(LOG_ERR,"Reading config failed. For usage, try -h.");
     return -1;
@@ -424,9 +422,9 @@
     }
   }
 
-  if(options.RunAsDaemon && !have_daemonized) {
-    daemonize();
-    have_daemonized = 1;
+  if(options.RunAsDaemon) {
+    /* XXXX Can we delay this any more? */
+    finish_daemon();
   }
 
   /* write our pid to the pid file, if we do not have write permissions we will log a warning */
@@ -633,6 +631,10 @@
   if (init_from_config(argc,argv) < 0)
     return -1;
 
+  if (options.RunAsDaemon) {
+    start_daemon();
+  }
+
   if(options.ORPort) { /* only spawn dns handlers if we're a router */
     dns_init(); /* initialize the dns resolve tree, and spawn workers */
   }



More information about the tor-commits mailing list