/* See LICENSE file for copyright and license details. */ #include #include #include void boot(void); void shut(char); int main(void) { int sig; sigset_t set; size_t i; if (getpid() != 1) return 1; chdir("/"); sigfillset(&set); sigprocmask(SIG_BLOCK, &set, NULL); nice(15); boot(); restart: while (1) { sigwait(&set, &sig); switch (sig) { case SIGUSR1: shut('p'); goto restart; case SIGCHLD: case SIGALRM: while (waitpid(-1, NULL, WNOHANG) > 0) ; goto restart; case SIGINT: shut('r'); goto restart; } } /* not reachable */ return 0; }