static void askconsole(struct init_action *a) { char line[256], *tty, *split; int i; tty = get_cmdline_val("console", line, sizeof(line)); if (tty != NULL) { split = strchr(tty, ','); if (split != NULL) *split = '\0'; if (!dev_exist(tty)) { DEBUG(4, "skipping %s\n", tty); return; } console = strdup(tty); a->id = strdup(tty); } else { console = NULL; a->id = NULL; } a->tout.cb = respawn; for (i = MAX_ARGS - 1; i >= 1; i--) a->argv[i] = a->argv[i - 1]; a->argv[0] = ask; a->respawn = 500; a->proc.cb = child_exit; fork_worker(a); }
static void rcrespawn(struct init_action *a) { a->tout.cb = respawn; a->respawn = 500; a->proc.cb = child_exit; fork_worker(a); }
/* run when a worker dies */ static void worker_died(pid_t pid, int status, unsigned id) { if (do_exit) return; syslog(LOG_INFO, "worker[%u] PID:%d died with status=%d, respawning", id, (int)pid, status); fork_worker(id); }
static void askfirst(struct init_action *a) { int i; if (!dev_exist(a->id) || (console && !strcmp(console, a->id))) { DEBUG(4, "Skipping %s\n", a->id); return; } a->tout.cb = respawn; for (i = MAX_ARGS - 1; i >= 1; i--) a->argv[i] = a->argv[i - 1]; a->argv[0] = ask; a->respawn = 500; a->proc.cb = child_exit; fork_worker(a); }
static void run_master(void) { unsigned id; size_t running = worker_processes; master_selfwake = mog_selfwake_new(); siginit(master_wakeup_handler); for (id = 0; id < worker_processes; id++) fork_worker(id); while (running > 0) { mog_selfwake_wait(master_selfwake); if (sigchld_hit) sigchld_handler(); if (do_upgrade) upgrade_handler(); if (do_exit) running = mog_kill_each_worker(SIGQUIT); } }
static void respawn(struct uloop_timeout *tout) { struct init_action *a = container_of(tout, struct init_action, tout); fork_worker(a); }