mysignal(SIGQUIT, sigterm, 0);
mysignal(SIGQUIT, sigquit, 0);
int main(int argc, char *argv[]){	int c, i, n, daemon, version, pid_fd, null_fd;	struct server *s;	char buf[10];	struct rlimit rl;	struct passwd *pwd;	progname = argv[0];	daemon = 1;	version = 0;	while ((c = getopt(argc, argv, "ndv")) != EOF) {		switch(c) {		case 'n':			daemon = 0;			break;		case 'd':			debug = 1;			break;		case 'v':			version = 1;			break;		default:			die(0, "usage: %s [ -ndv ]", progname);			break;		}	}	if (version) {		fprintf(stderr, "%s\n", server_version);		return 0;	}	if (getrlimit(RLIMIT_NOFILE, &rl) == -1)		die("getrlimit", 0);	n = rl.rlim_cur = rl.rlim_max;	if (debug)		fprintf(stderr, "Number of fds available: %d\n", n);	setrlimit(RLIMIT_NOFILE, &rl);	for (i = 3; i < n; i++)		close(i);	null_fd = open(devnull, O_RDWR);	if (null_fd == -1)		die("open", "Cannot open %d", devnull);	while (null_fd < 3)		null_fd = dup(null_fd);	config();	s = servers;	while (s) {		startup_server(s);		s = s->next;	}	if (rootdir) {		if (chroot(rootdir) == -1)			die("chroot", 0);		if (chdir("/") == -1)			die("chdir", 0);	}	setuid(geteuid());	if (geteuid() == 0) {		if (user_name == 0)			die(0, "No user specified.");		pwd = getpwnam(user_name);		if (pwd == 0 || pwd->pw_uid == 0)			die(0, "Invalid user name.");		if (initgroups(user_name, pwd->pw_gid) == -1)			die("initgroups", 0);		if (setgid(pwd->pw_gid) == -1)			die("setgid", 0);		if (stayroot) {			if (seteuid(pwd->pw_uid) == -1)				die("seteuid", 0);		} else {			if (setuid(pwd->pw_uid) == -1)				die("setuid", 0);		}	}	if (getrlimit(RLIMIT_CORE, &rl) == -1)		die("getrlimit", 0);	if (coredir) {		rl.rlim_cur = rl.rlim_max;		if (chdir(coredir) == -1)			die("chdir", 0);	} else {		rl.rlim_cur = 0;		chdir("/");	}	setrlimit(RLIMIT_CORE, &rl);	umask(fcm);	if (pid_filename) {		pid_fd = open(pid_filename, O_WRONLY | O_CREAT,			      DEFAULT_FILEMODE);		if (pid_fd == -1)			die("open", "Cannot open PID file");	}	else		pid_fd = -1;	dup2(null_fd, 0);	dup2(null_fd, 1);	dup2(null_fd, 2);	close(null_fd);	if (daemon) {		if (fork())			_exit(0);		setsid();		if (fork())			_exit(0);	}	mysignal(SIGCHLD, sigchld, SA_NOCLDSTOP);	mysignal(SIGHUP,  sighup, 0);	mysignal(SIGTERM, sigterm, 0);	mysignal(SIGINT,  sigterm, 0);	mysignal(SIGQUIT, sigterm, 0);	mysignal(SIGUSR1, sigusr1, 0);	mysignal(SIGUSR2, sigusr2, 0);	mysignal(SIGWINCH, sigwinch, 0);	mysignal(SIGPIPE, SIG_IGN, 0);	my_pid = getpid();	if (pid_fd != -1) {		ftruncate(pid_fd, 0);		sprintf(buf, "%d\n", my_pid);		write(pid_fd, buf, strlen(buf));		close(pid_fd);	}	gotsighup = 1;	gotsigterm = 0;	gotsigusr1 = 0;	gotsigusr2 = 0;	gotsigwinch = 1;	gotsigchld = 0;	time(&startuptime);	time(&current_time);	base64initialize();	httpd_main();	return 0;}