diff options
author | Eric Andersen | 1999-12-10 08:25:07 +0000 |
---|---|---|
committer | Eric Andersen | 1999-12-10 08:25:07 +0000 |
commit | 2cb55077e2f65f17dbc8933eec47760bcc2a6ba1 (patch) | |
tree | a788718415ded192938d7c7a3661d0cab8cd8afe /init | |
parent | c5ff0165adac767d37103baa875c2f86bb43c0e1 (diff) | |
download | busybox-2cb55077e2f65f17dbc8933eec47760bcc2a6ba1.zip busybox-2cb55077e2f65f17dbc8933eec47760bcc2a6ba1.tar.gz |
Added poweroff (and adjusted init to use it). Inlined function
calls to code only called once in tee. Made BB_KLOGD and option.
-Erik
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 17 | ||||
-rw-r--r-- | init/poweroff.c | 31 | ||||
-rw-r--r-- | init/reboot.c | 2 |
3 files changed, 44 insertions, 6 deletions
diff --git a/init/init.c b/init/init.c index d2e9a7e..3c800b9 100644 --- a/init/init.c +++ b/init/init.c @@ -336,9 +336,9 @@ static pid_t run(const char * const* command, } /* Log the process name and args */ - message(LOG, "Starting pid %d, console %s: '", getpid(), terminal); - while ( *cmd) message(LOG, "%s ", *cmd++); - message(LOG, "'\r\n"); + message(LOG|CONSOLE, "Starting pid %d, console %s: '", getpid(), terminal); + while ( *cmd) message(LOG|CONSOLE, "%s ", *cmd++); + message(LOG|CONSOLE, "'\r\n"); /* Now run it. The new program will take over this PID, * so nothing further in init.c should be run. */ @@ -418,8 +418,10 @@ static void halt_signal(int sig) "The system is halted. Press CTRL-ALT-DEL or turn off power\r\n"); sync(); #ifndef DEBUG_INIT - reboot(RB_HALT_SYSTEM); - //reboot(RB_POWER_OFF); + if (sig == SIGUSR2) + reboot(RB_POWER_OFF); + else + reboot(RB_HALT_SYSTEM); #endif exit(0); } @@ -514,8 +516,11 @@ extern int init_main(int argc, char **argv) } else message(CONSOLE|LOG, "Mounting /proc: failed!\n"); +fprintf(stderr, "got proc\n"); + /* Make sure there is enough memory to do something useful. */ check_memory(); +fprintf(stderr, "got check_memory\n"); /* Check if we are supposed to be in single user mode */ if ( argc > 1 && (!strcmp(argv[1], "single") || @@ -524,6 +529,7 @@ extern int init_main(int argc, char **argv) tty1_command = shell_command; tty2_command = shell_command; } +fprintf(stderr, "got single\n"); /* Make sure an init script exists before trying to run it */ if (single==FALSE && stat(INITSCRIPT, &statbuf)==0) { @@ -535,6 +541,7 @@ extern int init_main(int argc, char **argv) /* Make sure /sbin/getty exists before trying to run it */ if (stat(GETTY, &statbuf)==0) { char* where; +fprintf(stderr, "\n"); wait_for_enter_tty2 = FALSE; where = strrchr( console, '/'); if ( where != NULL) { diff --git a/init/poweroff.c b/init/poweroff.c new file mode 100644 index 0000000..405ca3f --- /dev/null +++ b/init/poweroff.c @@ -0,0 +1,31 @@ +/* + * Mini poweroff implementation for busybox + * + * + * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "internal.h" +#include <signal.h> + +extern int +poweroff_main(int argc, char ** argv) +{ + /* don't assume init's pid == 1 */ + exit( kill(findInitPid(), SIGUSR2)); +} diff --git a/init/reboot.c b/init/reboot.c index ff2c6ad..1339a60 100644 --- a/init/reboot.c +++ b/init/reboot.c @@ -27,5 +27,5 @@ extern int reboot_main(int argc, char ** argv) { /* don't assume init's pid == 1 */ - exit( kill(findInitPid(), SIGUSR2)); + exit( kill(findInitPid(), SIGINT)); } |