Fixed a bug in the pid writing function, which couldn't be
[silc.git] / apps / silcd / silcd.c
index 8915ab1bac18f2c164ab88f36c4f9584d27da07e..bb8dc0d44d14b67f3ea8274b25053504e0700f7a 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);