Fixed a bug in the pid writing function, which couldn't be
[silc.git] / apps / silcd / silcd.c
index 35693a717f1f5421c4b81c6b5baa65754a2af79c..af9d6172b14144ce8e401f53f8a3743089cebe41 100644 (file)
@@ -402,11 +402,6 @@ int main(int argc, char **argv)
   silc_schedule_signal_register(silcd->schedule, SIGTERM, stop_server, NULL);
   silc_schedule_signal_register(silcd->schedule, SIGINT, stop_server, NULL);
 
-  /* Drop root if we are not in debug mode, so you don't need to bother about
-     file writing permissions and so on */
-  if (!silc_debug)
-    silc_server_drop_privs(silcd);
-
   if (!foreground) {
     /* Before running the server, fork to background. */
     silc_server_daemonise(silcd);
@@ -420,6 +415,11 @@ int main(int argc, char **argv)
     }
   }
 
+  /* Drop root if we are not in debug mode, so you don't need to bother about
+     file writing permissions and so on */
+  if (!silc_debug)
+    silc_server_drop_privs(silcd);
+
   /* Run the server. When this returns the server has been stopped
      and we will exit. */
   silc_server_run(silcd);