+ else if(logsyslog) {
+ /* If we're running under some kind of daemon supervisor then we may want
+ * to log to syslog but not to go into background */
+ openlog(progname, LOG_PID, LOG_DAEMON);
+ log_default = &log_syslog;
+ }
+ disorder_info("process ID %lu", (unsigned long)getpid());
+ fix_path();
+ srand(xtime(0)); /* don't start the same every time */
+ /* gcrypt initialization */
+ if(!gcry_check_version(NULL))
+ disorder_fatal(0, "gcry_check_version failed");
+ gcry_control(GCRYCTL_INIT_SECMEM, 1);
+ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+ /* make sure we can't have more than FD_SETSIZE files open (event.c does
+ * check but this provides an additional line of defence) */
+ if(getrlimit(RLIMIT_NOFILE, rl) < 0)
+ disorder_fatal(errno, "getrlimit RLIMIT_NOFILE");
+ if(rl->rlim_cur > FD_SETSIZE) {
+ rl->rlim_cur = FD_SETSIZE;
+ if(setrlimit(RLIMIT_NOFILE, rl) < 0)
+ disorder_fatal(errno, "setrlimit to reduce RLIMIT_NOFILE to %lu",
+ (unsigned long)rl->rlim_cur);
+ disorder_info("set RLIM_NOFILE to %lu", (unsigned long)rl->rlim_cur);
+ } else
+ disorder_info("RLIM_NOFILE is %lu", (unsigned long)rl->rlim_cur);