static int run_loop(void) { while (1) { svc_monitor(); plugin_monitor(); } return 0; }
/* * SIGCHLD: one of our children has died */ static void sigchld_cb(uev_ctx_t *UNUSED(ctx), uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events)) { svc_monitor(waitpid(-1, NULL, WNOHANG)); }
static int client(int argc, char *argv[]) { int fd; int c; struct option long_options[] = { {"debug", 0, NULL, 'd'}, {"help", 0, NULL, 'h'}, {NULL, 0, NULL, 0} }; struct init_request rq = { .magic = INIT_MAGIC, .cmd = 0 }; while ((c = getopt_long (argc, argv, "h?d", long_options, NULL)) != EOF) { switch(c) { case 'd': rq.cmd = INIT_CMD_DEBUG; break; case 'h': case '?': return usage(0); default: return usage(1); } } if (!rq.cmd) { if (argc < 2) { fprintf(stderr, "Missing runlevel.\n"); return 1; } rq.cmd = INIT_CMD_RUNLVL; rq.runlevel = (int)argv[1][0]; } if (!fexist(FINIT_FIFO)) { fprintf(stderr, "/sbin/init does not support %s!\n", FINIT_FIFO); return 1; } fd = open(FINIT_FIFO, O_WRONLY); if (-1 == fd) { perror("Failed opening " FINIT_FIFO); return 1; } write(fd, &rq, sizeof(rq)); close(fd); return 0; } static int run_loop(void) { int delay = DELAY_TTY ?: 1; _d("Entering main loop ..."); while (1) { svc_monitor(); plugin_monitor(); /* Delayed start of TTYs to let the system stabilize * after switching runlevels. */ if (delay) { if (--delay == 0) tty_runlevel(runlevel); continue; } } return 0; }