#include <sys/vt.h> /* for vt_stat */
#include <sys/ioctl.h>
-#define VT_CONSOLE "/dev/console" /* Logical system console */
+#define DEV_CONSOLE "/dev/console" /* Logical system console */
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
#define VT_LOG "/dev/tty3" /* Virtual console */
#define LOG 0x1
#define CONSOLE 0x2
-static char *console = VT_CONSOLE;
+static char *console = DEV_CONSOLE;
static char *second_console = VT_SECONDARY;
static char *log = VT_LOG;
static int kernel_version = 0;
va_end(arguments);
}
if (device & CONSOLE) {
- if ((fd = device_open(console, O_WRONLY|O_NOCTTY|O_NDELAY)) >= 0) {
+ /* Always send console messages to /dev/console so people will see them. */
+ if ((fd = device_open(DEV_CONSOLE, O_WRONLY|O_NOCTTY|O_NDELAY)) >= 0) {
va_start(arguments, fmt);
vdprintf(fd, fmt, arguments);
va_end(arguments);
/* this is linux virtual tty */
snprintf( the_console, sizeof the_console, "/dev/tty%d", vt.v_active );
} else {
- console = VT_CONSOLE;
+ console = DEV_CONSOLE;
tried_devcons++;
}
}
/* Can't open selected console -- try /dev/console */
if (!tried_devcons) {
tried_devcons++;
- console = VT_CONSOLE;
+ console = DEV_CONSOLE;
continue;
}
/* Can't open selected console -- try vt1 */
pid_t pid1 = 0;
pid_t pid2 = 0;
struct stat statbuf;
- const char* const init_commands[] = { INITSCRIPT, INITSCRIPT, 0};
- const char* const shell_commands[] = { SHELL, "-" SHELL, 0};
- const char* const* tty0_commands = shell_commands;
- const char* const* tty1_commands = shell_commands;
+ const char* const rc_script_command[] = { INITSCRIPT, INITSCRIPT, 0};
+ const char* const shell_command[] = { SHELL, "-" SHELL, 0};
+ const char* const* tty0_command = shell_command;
+ const char* const* tty1_command = shell_command;
+#ifdef BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS
+ const char* const rc_exit_command[] = BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS;
+#endif
+
#ifdef DEBUG_INIT
char *hello_msg_format =
"init(%d) started: BusyBox v%s (%s) multi-call binary\r\n";
/* Make sure an init script exists before trying to run it */
if (run_rc == TRUE && stat(INITSCRIPT, &statbuf)==0) {
wait_for_enter = FALSE;
- tty0_commands = init_commands;
+ tty0_command = rc_script_command;
}
pid_t wpid;
int status;
- if (pid1 == 0 && tty0_commands) {
- pid1 = run(tty0_commands, console, wait_for_enter);
+ if (pid1 == 0 && tty0_command) {
+ pid1 = run(tty0_command, console, wait_for_enter);
}
- if (pid2 == 0 && tty1_commands && second_console) {
- pid2 = run(tty1_commands, second_console, TRUE);
+ if (pid2 == 0 && tty1_command && second_console) {
+ pid2 = run(tty1_command, second_console, TRUE);
}
wpid = wait(&status);
if (wpid > 0 ) {
if (wpid == pid1) {
if (run_rc == FALSE) {
pid1 = 0;
- }
-#if 0
-/* Turn this on to start a shell on the console if the init script exits.... */
+ }
+#ifdef BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS
else {
+ pid1 = 0;
run_rc=FALSE;
wait_for_enter=TRUE;
- tty0_commands=shell_commands;
+ tty0_command=rc_exit_command;
}
#endif
}