X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fmain.c;h=bc913395f8b56e784709aac25ed9839ca1820f73;hb=1aa006c5960c17ccb941fc850b29d49cd5c6d1c3;hp=5e2b3e19981949601d85ee212ddc6275a1817b69;hpb=00a40eca6f9ac786c627639e2c7fd1e0704cb49d;p=umurmur.git diff --git a/src/main.c b/src/main.c index 5e2b3e1..bc91339 100644 --- a/src/main.c +++ b/src/main.c @@ -199,6 +199,10 @@ void daemonize() for (i = getdtablesize(); i >= 0; --i) close(i); /* close all descriptors */ +#ifdef USE_GNUTLS + gnutls_global_init(); +#endif + i = open("/dev/null",O_RDWR); (void)dup(i); (void)dup(i); @@ -319,6 +323,13 @@ int main(int argc, char **argv) if (pidfile != NULL) lockfile(pidfile); +#ifdef POSIX_PRIORITY_SCHEDULING + /* Set the scheduling policy, has to be called after daemonizing + * but before we drop privileges */ + if (realtime) + setscheduler(); +#endif + switch_user(); /* Reopen log file. If user switch results in access denied, we catch @@ -328,6 +339,15 @@ int main(int argc, char **argv) } else Log_init(true); +#ifdef POSIX_PRIORITY_SCHEDULING + /* We still want to set scheduling policy if nodaemon is specified, + * but if we are daemonizing setscheduler() will be called above */ + if (nodaemon) { + if (realtime) + setscheduler(); + } +#endif + signal(SIGCHLD, SIG_IGN); /* ignore child */ signal(SIGTSTP, SIG_IGN); /* ignore tty signals */ signal(SIGTTOU, SIG_IGN); @@ -356,11 +376,6 @@ int main(int argc, char **argv) Sharedmemory_init( bindport, bindport6 ); #endif -#ifdef POSIX_PRIORITY_SCHEDULING - if (realtime) - setscheduler(); -#endif - Server_run(); #ifdef USE_SHAREDMEMORY_API