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