#endif
/* Allowed init action types */
-#define SYSINIT 0x001
-#define RESPAWN 0x002
-#define ASKFIRST 0x004
-#define WAIT 0x008
-#define ONCE 0x010
-#define CTRLALTDEL 0x020
-#define SHUTDOWN 0x040
-#define RESTART 0x080
+#define SYSINIT 0x01
+#define RESPAWN 0x02
+/* like respawn, but wait for <Enter> to be pressed on tty: */
+#define ASKFIRST 0x04
+#define WAIT 0x08
+#define ONCE 0x10
+#define CTRLALTDEL 0x20
+#define SHUTDOWN 0x40
+#define RESTART 0x80
#define STR_SYSINIT "\x01"
#define STR_RESPAWN "\x02"
sigemptyset(&nmask);
sigaddset(&nmask, SIGCHLD);
sigprocmask(SIG_BLOCK, &nmask, &omask);
- pid = vfork();
+ if (BB_MMU && (a->action_type & ASKFIRST))
+ pid = fork();
+ else
+ pid = vfork();
sigprocmask(SIG_SETMASK, &omask, NULL);
if (pid < 0)
}
#endif
- /* NB: on NOMMU we can't wait for input in child */
+ /* NB: on NOMMU we can't wait for input in child, so
+ * "askfirst" will work the same as "respawn". */
if (BB_MMU && (a->action_type & ASKFIRST)) {
static const char press_enter[] ALIGN1 =
#ifdef CUSTOMIZED_BANNER
for (a = init_action_list; a; a = tmp) {
tmp = a->next;
- if (a->action_type == action_type) {
+ if (a->action_type & action_type) {
// Pointless: run() will error out if open of device fails.
///* a->terminal of "" means "init's console" */
//if (a->terminal[0] && access(a->terminal, R_OK | W_OK)) {
fclose(file);
}
+#if ENABLE_FEATURE_USE_INITTAB
static void reload_signal(int sig ATTRIBUTE_UNUSED)
{
struct init_action *a, *tmp;
delete_init_action(a);
}
}
- run_actions(RESPAWN);
+ run_actions(RESPAWN | ASKFIRST);
}
+#endif
int init_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int init_main(int argc ATTRIBUTE_UNUSED, char **argv)
run_actions(ONCE);
/* Redefine SIGHUP to reread /etc/inittab */
- if (ENABLE_FEATURE_USE_INITTAB)
- signal(SIGHUP, reload_signal);
- else
- signal(SIGHUP, SIG_IGN);
+#if ENABLE_FEATURE_USE_INITTAB
+ signal(SIGHUP, reload_signal);
+#else
+ signal(SIGHUP, SIG_IGN);
+#endif
/* Now run the looping stuff for the rest of forever */
while (1) {
- /* run the respawn stuff */
- run_actions(RESPAWN);
-
- /* run the askfirst stuff */
- run_actions(ASKFIRST);
+ /* run the respawn/askfirst stuff */
+ run_actions(RESPAWN | ASKFIRST);
/* Don't consume all CPU time -- sleep a bit */
sleep(1);