sprintf(buf, "-%d\n", getpgrp());
sprintf(buf, "-%d\n", (int) getpgrp());
int main(int argc, char *argv[]){	int c, i, version, pid_fd, null_fd, tee;	struct server *s;	char buf[10];	struct rlimit rl;	const char *message;	const char *config_filename;	my_pid = getpid();	progname = argv[0];	am_daemon = 1;	version = 0;	config_filename = 0;	tee = 0;	while ((c = getopt(argc, argv, "ndvf:t")) != EOF) {		switch(c) {		case 'n':			am_daemon = 0;			break;		case 'd':			debug = 1;			break;		case 'v':			version = 1;			break;		case 'f':			if (config_filename == 0)				config_filename = optarg;			else				die(0, "You may not specify more than one configuration file.");			break;		case 't':			tee = 1;			break;		default:			die(0, "usage: %s [ -ndvt ] [ -f configuration_file ]", progname);			break;		}	}	if (version) {		fprintf(stderr, "%s\n", server_version);		return 0;	}	if (getrlimit(RLIMIT_NOFILE, &rl) == -1)		die("getrlimit", 0);	nfiles = rl.rlim_cur = rl.rlim_max;	setrlimit(RLIMIT_NOFILE, &rl);	if (am_daemon)		for (i = 3; i < nfiles; i++)			close(i);	null_fd = open(devnull, O_RDWR);	if (null_fd == -1)		die("open", "Cannot open %s", devnull);	while (null_fd < 3) {		null_fd = dup(null_fd);		if (null_fd == -1)			die("dup", 0);	}	message = config(config_filename);	if (message)		die(0, "%s", message);	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 (server_uid == 0)			die(0, "No user specified.");		if (setgroups(0, 0) == -1)			if (setgroups(1, &server_gid) == -1)				die("setgroups", 0);		if (setgid(server_gid) == -1)			die("setgid", 0);		if (stayroot) {			if (seteuid(server_uid) == -1)				die("seteuid", 0);			amroot = 1;		} else {			if (setuid(server_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, 0666);		if (pid_fd == -1)			die("open", "Cannot open PID file");	} else		pid_fd = -1;	current_time = time(0);	if (init_logs(tee) == -1)		die("open", "Cannot open log files");	dup2(null_fd, 0);	dup2(null_fd, 1);	dup2(null_fd, 2);	close(null_fd);	if (am_daemon) {		if (fork())			_exit(0);		setsid();		if (fork())			_exit(0);		for (i = 1; i < tuning.num_processes; i++) {			if (fork() == 0) {				if (pid_fd != -1) {					close(pid_fd);					pid_fd = -1;				}				break;			}		}	}	mysignal(SIGCHLD, sighandler);	mysignal(SIGHUP, sighandler);	mysignal(SIGTERM, sighandler);	mysignal(SIGINT, sighandler);	mysignal(SIGQUIT, sighandler);	mysignal(SIGUSR1, sighandler);	mysignal(SIGUSR2, sighandler);	mysignal(SIGPIPE, SIG_IGN);	mysignal(SIGWINCH, sighandler);	my_pid = getpid();	if (pid_fd != -1) {		ftruncate(pid_fd, 0);		if (tuning.num_processes > 1)			sprintf(buf, "-%d\n", getpgrp());		else			sprintf(buf, "%d\n", my_pid);		write(pid_fd, buf, strlen(buf));		close(pid_fd);	}	if (init_buffers() == -1)		return 1;	httpd_main();	return 0;}