init: de-indent a block of code
This commit is contained in:
parent
b716754199
commit
966bb43766
30
init/init.c
30
init/init.c
@ -316,7 +316,7 @@ static void open_stdio_to_tty(const char* tty_name, int fail)
|
||||
close(0);
|
||||
if ((device_open(tty_name, O_RDWR)) < 0) {
|
||||
dup2(1, 0); /* restore fd #0 - avoid nasty surprises */
|
||||
message(L_LOG | L_CONSOLE, "can't open %s: %s",
|
||||
message(L_LOG | L_CONSOLE, "Can't open %s: %s",
|
||||
tty_name, strerror(errno));
|
||||
if (fail)
|
||||
_exit(1);
|
||||
@ -342,21 +342,17 @@ static pid_t run(const struct init_action *a)
|
||||
char *cmd[INIT_BUFFS_SIZE];
|
||||
char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */
|
||||
sigset_t nmask, omask;
|
||||
static const char press_enter[] =
|
||||
#ifdef CUSTOMIZED_BANNER
|
||||
#include CUSTOMIZED_BANNER
|
||||
#endif
|
||||
"\nPlease press Enter to activate this console. ";
|
||||
|
||||
/* Block sigchild while forking. */
|
||||
sigemptyset(&nmask);
|
||||
sigaddset(&nmask, SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, &nmask, &omask);
|
||||
|
||||
if ((pid = fork()) == 0) {
|
||||
/* Clean up */
|
||||
pid = fork();
|
||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
|
||||
if (pid)
|
||||
return pid;
|
||||
|
||||
/* Reset signal handlers that were set by the parent process */
|
||||
signal(SIGUSR1, SIG_DFL);
|
||||
signal(SIGUSR2, SIG_DFL);
|
||||
@ -381,7 +377,7 @@ static pid_t run(const struct init_action *a)
|
||||
|
||||
/* Now fork off another process to just hang around */
|
||||
if ((pid = fork()) < 0) {
|
||||
message(L_LOG | L_CONSOLE, "can't fork");
|
||||
message(L_LOG | L_CONSOLE, "Can't fork");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -400,7 +396,7 @@ static pid_t run(const struct init_action *a)
|
||||
|
||||
/* Use a temporary process to steal the controlling tty. */
|
||||
if ((pid = fork()) < 0) {
|
||||
message(L_LOG | L_CONSOLE, "can't fork");
|
||||
message(L_LOG | L_CONSOLE, "Can't fork");
|
||||
_exit(1);
|
||||
}
|
||||
if (pid == 0) {
|
||||
@ -468,6 +464,11 @@ static pid_t run(const struct init_action *a)
|
||||
|
||||
#if !defined(__UCLIBC__) || defined(__ARCH_HAS_MMU__)
|
||||
if (a->action & ASKFIRST) {
|
||||
static const char press_enter[] =
|
||||
#ifdef CUSTOMIZED_BANNER
|
||||
#include CUSTOMIZED_BANNER
|
||||
#endif
|
||||
"\nPlease press Enter to activate this console. ";
|
||||
char c;
|
||||
/*
|
||||
* Save memory by not exec-ing anything large (like a shell)
|
||||
@ -477,7 +478,7 @@ static pid_t run(const struct init_action *a)
|
||||
* be allowed to start a shell or whatever an init script
|
||||
* specifies.
|
||||
*/
|
||||
messageD(L_LOG, "Waiting for enter to start '%s'"
|
||||
messageD(L_LOG, "waiting for enter to start '%s'"
|
||||
"(pid %d, tty '%s')\n",
|
||||
cmdpath, getpid(), a->terminal);
|
||||
full_write(1, press_enter, sizeof(press_enter) - 1);
|
||||
@ -485,7 +486,6 @@ static pid_t run(const struct init_action *a)
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Log the process name and args */
|
||||
message(L_LOG, "starting pid %d, tty '%s': '%s'",
|
||||
getpid(), a->terminal, cmdpath);
|
||||
@ -502,7 +502,6 @@ static pid_t run(const struct init_action *a)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now run it. The new program will take over this PID,
|
||||
* so nothing further in init.c should be run. */
|
||||
BB_EXECVP(cmdpath, cmd);
|
||||
@ -512,9 +511,6 @@ static pid_t run(const struct init_action *a)
|
||||
cmdpath, strerror(errno));
|
||||
_exit(-1);
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
return pid;
|
||||
}
|
||||
|
||||
static int waitfor(const struct init_action *a, pid_t pid)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user