diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-12-10 08:25:07 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-12-10 08:25:07 +0000 |
commit | 2cb55077e2f65f17dbc8933eec47760bcc2a6ba1 (patch) | |
tree | a788718415ded192938d7c7a3661d0cab8cd8afe /init | |
parent | c5ff0165adac767d37103baa875c2f86bb43c0e1 (diff) | |
download | busybox-w32-2cb55077e2f65f17dbc8933eec47760bcc2a6ba1.tar.gz busybox-w32-2cb55077e2f65f17dbc8933eec47760bcc2a6ba1.tar.bz2 busybox-w32-2cb55077e2f65f17dbc8933eec47760bcc2a6ba1.zip |
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 d2e9a7e97..3c800b9b2 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -336,9 +336,9 @@ static pid_t run(const char * const* command, | |||
336 | } | 336 | } |
337 | 337 | ||
338 | /* Log the process name and args */ | 338 | /* Log the process name and args */ |
339 | message(LOG, "Starting pid %d, console %s: '", getpid(), terminal); | 339 | message(LOG|CONSOLE, "Starting pid %d, console %s: '", getpid(), terminal); |
340 | while ( *cmd) message(LOG, "%s ", *cmd++); | 340 | while ( *cmd) message(LOG|CONSOLE, "%s ", *cmd++); |
341 | message(LOG, "'\r\n"); | 341 | message(LOG|CONSOLE, "'\r\n"); |
342 | 342 | ||
343 | /* Now run it. The new program will take over this PID, | 343 | /* Now run it. The new program will take over this PID, |
344 | * so nothing further in init.c should be run. */ | 344 | * so nothing further in init.c should be run. */ |
@@ -418,8 +418,10 @@ static void halt_signal(int sig) | |||
418 | "The system is halted. Press CTRL-ALT-DEL or turn off power\r\n"); | 418 | "The system is halted. Press CTRL-ALT-DEL or turn off power\r\n"); |
419 | sync(); | 419 | sync(); |
420 | #ifndef DEBUG_INIT | 420 | #ifndef DEBUG_INIT |
421 | reboot(RB_HALT_SYSTEM); | 421 | if (sig == SIGUSR2) |
422 | //reboot(RB_POWER_OFF); | 422 | reboot(RB_POWER_OFF); |
423 | else | ||
424 | reboot(RB_HALT_SYSTEM); | ||
423 | #endif | 425 | #endif |
424 | exit(0); | 426 | exit(0); |
425 | } | 427 | } |
@@ -514,8 +516,11 @@ extern int init_main(int argc, char **argv) | |||
514 | } else | 516 | } else |
515 | message(CONSOLE|LOG, "Mounting /proc: failed!\n"); | 517 | message(CONSOLE|LOG, "Mounting /proc: failed!\n"); |
516 | 518 | ||
519 | fprintf(stderr, "got proc\n"); | ||
520 | |||
517 | /* Make sure there is enough memory to do something useful. */ | 521 | /* Make sure there is enough memory to do something useful. */ |
518 | check_memory(); | 522 | check_memory(); |
523 | fprintf(stderr, "got check_memory\n"); | ||
519 | 524 | ||
520 | /* Check if we are supposed to be in single user mode */ | 525 | /* Check if we are supposed to be in single user mode */ |
521 | if ( argc > 1 && (!strcmp(argv[1], "single") || | 526 | if ( argc > 1 && (!strcmp(argv[1], "single") || |
@@ -524,6 +529,7 @@ extern int init_main(int argc, char **argv) | |||
524 | tty1_command = shell_command; | 529 | tty1_command = shell_command; |
525 | tty2_command = shell_command; | 530 | tty2_command = shell_command; |
526 | } | 531 | } |
532 | fprintf(stderr, "got single\n"); | ||
527 | 533 | ||
528 | /* Make sure an init script exists before trying to run it */ | 534 | /* Make sure an init script exists before trying to run it */ |
529 | if (single==FALSE && stat(INITSCRIPT, &statbuf)==0) { | 535 | if (single==FALSE && stat(INITSCRIPT, &statbuf)==0) { |
@@ -535,6 +541,7 @@ extern int init_main(int argc, char **argv) | |||
535 | /* Make sure /sbin/getty exists before trying to run it */ | 541 | /* Make sure /sbin/getty exists before trying to run it */ |
536 | if (stat(GETTY, &statbuf)==0) { | 542 | if (stat(GETTY, &statbuf)==0) { |
537 | char* where; | 543 | char* where; |
544 | fprintf(stderr, "\n"); | ||
538 | wait_for_enter_tty2 = FALSE; | 545 | wait_for_enter_tty2 = FALSE; |
539 | where = strrchr( console, '/'); | 546 | where = strrchr( console, '/'); |
540 | if ( where != NULL) { | 547 | if ( where != NULL) { |
diff --git a/init/poweroff.c b/init/poweroff.c new file mode 100644 index 000000000..405ca3fe2 --- /dev/null +++ b/init/poweroff.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Mini poweroff implementation for busybox | ||
3 | * | ||
4 | * | ||
5 | * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include "internal.h" | ||
24 | #include <signal.h> | ||
25 | |||
26 | extern int | ||
27 | poweroff_main(int argc, char ** argv) | ||
28 | { | ||
29 | /* don't assume init's pid == 1 */ | ||
30 | exit( kill(findInitPid(), SIGUSR2)); | ||
31 | } | ||
diff --git a/init/reboot.c b/init/reboot.c index ff2c6ad18..1339a60f4 100644 --- a/init/reboot.c +++ b/init/reboot.c | |||
@@ -27,5 +27,5 @@ extern int | |||
27 | reboot_main(int argc, char ** argv) | 27 | reboot_main(int argc, char ** argv) |
28 | { | 28 | { |
29 | /* don't assume init's pid == 1 */ | 29 | /* don't assume init's pid == 1 */ |
30 | exit( kill(findInitPid(), SIGUSR2)); | 30 | exit( kill(findInitPid(), SIGINT)); |
31 | } | 31 | } |