if (debug) log_d("child process %d created", pid);
pid_t spawn(const char *program, char *const argv[], char *const envp[], int fd, int efd, uid_t u, gid_t g, const char *curdir){	pid_t pid;	sigset_t set, oset;	sigfillset(&set);	sigprocmask(SIG_SETMASK, &set, &oset);#ifdef HAVE_VFORK	pid = vfork();#else	pid = fork();#endif	switch (pid) {	default:		setpgid(pid, pid);	case -1:		sigprocmask(SIG_SETMASK, &oset, 0);		return pid;	case 0:		setpgid(0, getpid());		mysignal(SIGCHLD, SIG_DFL);		mysignal(SIGHUP, SIG_DFL);		mysignal(SIGTERM, SIG_DFL);		mysignal(SIGINT, SIG_DFL);		mysignal(SIGQUIT, SIG_DFL);		mysignal(SIGUSR1, SIG_DFL);		mysignal(SIGUSR2, SIG_DFL);		mysignal(SIGPIPE, SIG_DFL);		sigprocmask(SIG_SETMASK, &oset, 0);		dup2(fd, 0);		dup2(fd, 1);		if (efd != -1)			dup2(efd, 2);		if (u) {			if (setuid(0) == -1)				_exit(1);			if (setgid(g) == -1)				_exit(2);			if (setuid(u) == -1)				_exit(3);		}		if (getuid() == 0 || geteuid() == 0)			_exit(4);		if (chdir(curdir) == -1)			_exit(5);		execve(program, argv, envp);		_exit(6);	}	return -1; /* not reached */}