diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-04-03 18:01:51 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-04-03 18:01:51 +0000 |
commit | c97ec34370f66771713809ab7da19b7fe923cffe (patch) | |
tree | 113cfd14600fe4ccb65e392eeb06e368df13f1ef | |
parent | 0f0c0b41ced8c30d382a0490719c79371260b9d1 (diff) | |
download | busybox-w32-c97ec34370f66771713809ab7da19b7fe923cffe.tar.gz busybox-w32-c97ec34370f66771713809ab7da19b7fe923cffe.tar.bz2 busybox-w32-c97ec34370f66771713809ab7da19b7fe923cffe.zip |
A patch from Matt Kraai that adds a new 'shutdown' action to busybox init. Now
you can specify an arbitrary behavior for 'ctrlaltdel' without that behavior
needing to be a reboot.
-rw-r--r-- | Changelog | 7 | ||||
-rw-r--r-- | applets/usage.h | 21 | ||||
-rw-r--r-- | docs/busybox.pod | 25 | ||||
-rw-r--r-- | include/usage.h | 21 | ||||
-rw-r--r-- | init.c | 23 | ||||
-rw-r--r-- | init/init.c | 23 | ||||
-rw-r--r-- | init/reboot.c | 4 | ||||
-rw-r--r-- | reboot.c | 4 | ||||
-rw-r--r-- | usage.h | 21 |
9 files changed, 103 insertions, 46 deletions
@@ -1,7 +1,12 @@ | |||
1 | 0.51pre | 1 | 0.51pre |
2 | * Erik Andersen -- added env applet | 2 | * Erik Andersen -- added env applet |
3 | * Erik Andersen -- Split utility.c into libbb | 3 | * Erik Andersen -- Split utility.c into libbb |
4 | * <fixme> | 4 | * Andreas Neuhaus <andy@fasta.fh-dortmund.de> -- fix for merging |
5 | kernel command line environment variables into child environment | ||
6 | for init.c | ||
7 | * Matt Kraai -- Added a new 'shutdown' action to busybox init. Now | ||
8 | you can specify arbitrary behavior for 'ctrlaltdel' without that | ||
9 | behavior needing to be a reboot. | ||
5 | 10 | ||
6 | 11 | ||
7 | -Erik Andersen, not yet released | 12 | -Erik Andersen, not yet released |
diff --git a/applets/usage.h b/applets/usage.h index 1ee2ab328..aa7f0af22 100644 --- a/applets/usage.h +++ b/applets/usage.h | |||
@@ -663,10 +663,15 @@ | |||
663 | "\n" \ | 663 | "\n" \ |
664 | " ::sysinit:/etc/init.d/rcS\n" \ | 664 | " ::sysinit:/etc/init.d/rcS\n" \ |
665 | " ::askfirst:/bin/sh\n" \ | 665 | " ::askfirst:/bin/sh\n" \ |
666 | " ::ctrlaltdel:/sbin/reboot\n" \ | ||
667 | " ::shutdown:/sbin/swapoff -a\n" \ | ||
668 | " ::shutdown:/bin/umount -a -r\n" \ | ||
666 | "\n" \ | 669 | "\n" \ |
667 | "if it detects that /dev/console is _not_ a serial console, it will also run:\n" \ | 670 | "if it detects that /dev/console is _not_ a serial console, it will also run:\n" \ |
668 | "\n" \ | 671 | "\n" \ |
669 | " tty2::askfirst:/bin/sh\n" \ | 672 | " tty2::askfirst:/bin/sh\n" \ |
673 | " tty3::askfirst:/bin/sh\n" \ | ||
674 | " tty4::askfirst:/bin/sh\n" \ | ||
670 | "\n" \ | 675 | "\n" \ |
671 | "If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \ | 676 | "If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \ |
672 | "\n" \ | 677 | "\n" \ |
@@ -692,7 +697,7 @@ | |||
692 | " <action>: \n" \ | 697 | " <action>: \n" \ |
693 | "\n" \ | 698 | "\n" \ |
694 | " Valid actions include: sysinit, respawn, askfirst, wait, \n" \ | 699 | " Valid actions include: sysinit, respawn, askfirst, wait, \n" \ |
695 | " once, and ctrlaltdel.\n" \ | 700 | " once, ctrlaltdel, and shutdown.\n" \ |
696 | "\n" \ | 701 | "\n" \ |
697 | " The available actions can be classified into two groups: actions\n" \ | 702 | " The available actions can be classified into two groups: actions\n" \ |
698 | " that are run only once, and actions that are re-run when the specified\n" \ | 703 | " that are run only once, and actions that are re-run when the specified\n" \ |
@@ -706,9 +711,12 @@ | |||
706 | " 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \ | 711 | " 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \ |
707 | " the specified task completes. 'once' actions are asyncronous,\n" \ | 712 | " the specified task completes. 'once' actions are asyncronous,\n" \ |
708 | " therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \ | 713 | " therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \ |
709 | " actions are run immediately before init causes the system to reboot\n" \ | 714 | " actions are run when the system detects that someone on the system\n" \ |
710 | " (unmounting filesystems with a 'ctrlaltdel' action is a very good\n" \ | 715 | " console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \ |
711 | " idea).\n" \ | 716 | " wants to run 'reboot' at this point to cause the system to reboot.\n" \ |
717 | " Finally the 'shutdown' action specifies the actions to taken when\n" \ | ||
718 | " init is told to reboot. Unmounting filesystems and disabling swap\n" \ | ||
719 | " is a very good here\n" \ | ||
712 | "\n" \ | 720 | "\n" \ |
713 | " Run repeatedly actions:\n" \ | 721 | " Run repeatedly actions:\n" \ |
714 | "\n" \ | 722 | "\n" \ |
@@ -759,8 +767,9 @@ | |||
759 | " #::respawn:/sbin/getty 57600 ttyS2\n" \ | 767 | " #::respawn:/sbin/getty 57600 ttyS2\n" \ |
760 | " \n" \ | 768 | " \n" \ |
761 | " # Stuff to do before rebooting\n" \ | 769 | " # Stuff to do before rebooting\n" \ |
762 | " ::ctrlaltdel:/bin/umount -a -r\n" \ | 770 | " ::ctrlaltdel:/sbin/reboot\n" \ |
763 | " ::ctrlaltdel:/sbin/swapoff -a\n" | 771 | " ::shutdown:/bin/umount -a -r\n" \ |
772 | " ::shutdown:/sbin/swapoff -a\n" | ||
764 | 773 | ||
765 | #define insmod_trivial_usage \ | 774 | #define insmod_trivial_usage \ |
766 | "[OPTION]... MODULE [symbol=value]..." | 775 | "[OPTION]... MODULE [symbol=value]..." |
diff --git a/docs/busybox.pod b/docs/busybox.pod index 644abc359..42944489a 100644 --- a/docs/busybox.pod +++ b/docs/busybox.pod | |||
@@ -906,10 +906,15 @@ it has the following default behavior: | |||
906 | 906 | ||
907 | ::sysinit:/etc/init.d/rcS | 907 | ::sysinit:/etc/init.d/rcS |
908 | ::askfirst:/bin/sh | 908 | ::askfirst:/bin/sh |
909 | ::ctrlaltdel:/sbin/reboot | ||
910 | ::shutdown:/sbin/swapoff -a | ||
911 | ::shutdown:/bin/umount -a -r | ||
909 | 912 | ||
910 | if it detects that /dev/console is _not_ a serial console, it will also run: | 913 | if it detects that /dev/console is _not_ a serial console, it will also run: |
911 | 914 | ||
912 | tty2::askfirst:/bin/sh | 915 | tty2::askfirst:/bin/sh |
916 | tty3::askfirst:/bin/sh | ||
917 | tty4::askfirst:/bin/sh | ||
913 | 918 | ||
914 | If you choose to use an /etc/inittab file, the inittab entry format is as follows: | 919 | If you choose to use an /etc/inittab file, the inittab entry format is as follows: |
915 | 920 | ||
@@ -935,7 +940,7 @@ If you choose to use an /etc/inittab file, the inittab entry format is as follow | |||
935 | <action>: | 940 | <action>: |
936 | 941 | ||
937 | Valid actions include: sysinit, respawn, askfirst, wait, | 942 | Valid actions include: sysinit, respawn, askfirst, wait, |
938 | once, and ctrlaltdel. | 943 | once, ctrlaltdel, and shutdown. |
939 | 944 | ||
940 | The available actions can be classified into two groups: actions | 945 | The available actions can be classified into two groups: actions |
941 | that are run only once, and actions that are re-run when the specified | 946 | that are run only once, and actions that are re-run when the specified |
@@ -949,9 +954,12 @@ If you choose to use an /etc/inittab file, the inittab entry format is as follow | |||
949 | 'wait' actions, like 'sysinit' actions, cause init to wait until | 954 | 'wait' actions, like 'sysinit' actions, cause init to wait until |
950 | the specified task completes. 'once' actions are asyncronous, | 955 | the specified task completes. 'once' actions are asyncronous, |
951 | therefore, init does not wait for them to complete. 'ctrlaltdel' | 956 | therefore, init does not wait for them to complete. 'ctrlaltdel' |
952 | actions are run immediately before init causes the system to reboot | 957 | actions are run when the system detects that someone on the system |
953 | (unmounting filesystems with a 'ctrlaltdel' action is a very good | 958 | console has pressed the CTRL-ALT-DEL key combination. Typically one |
954 | idea). | 959 | wants to run 'reboot' at this point to cause the system to reboot. |
960 | Finally the 'shutdown' action specifies the actions to taken when | ||
961 | init is told to reboot. Unmounting filesystems and disabling swap | ||
962 | is a very good here. | ||
955 | 963 | ||
956 | Run repeatedly actions: | 964 | Run repeatedly actions: |
957 | 965 | ||
@@ -984,10 +992,9 @@ Example /etc/inittab file: | |||
984 | tty4::respawn:/sbin/getty 38400 tty5 | 992 | tty4::respawn:/sbin/getty 38400 tty5 |
985 | tty5::respawn:/sbin/getty 38400 tty6 | 993 | tty5::respawn:/sbin/getty 38400 tty6 |
986 | 994 | ||
987 | 995 | ::ctrlaltdel:/sbin/reboot | |
988 | 996 | ::shutdown:/bin/umount -a -r | |
989 | ::ctrlaltdel:/bin/umount -a -r | 997 | ::shutdown:/sbin/swapoff -a |
990 | ::ctrlaltdel:/sbin/swapoff -a | ||
991 | 998 | ||
992 | 999 | ||
993 | ------------------------------- | 1000 | ------------------------------- |
@@ -2476,4 +2483,4 @@ Enrique Zanardi <ezanardi@ull.es> | |||
2476 | 2483 | ||
2477 | =cut | 2484 | =cut |
2478 | 2485 | ||
2479 | # $Id: busybox.pod,v 1.92 2001/03/15 21:20:25 markw Exp $ | 2486 | # $Id: busybox.pod,v 1.93 2001/04/03 18:01:51 andersen Exp $ |
diff --git a/include/usage.h b/include/usage.h index 1ee2ab328..aa7f0af22 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -663,10 +663,15 @@ | |||
663 | "\n" \ | 663 | "\n" \ |
664 | " ::sysinit:/etc/init.d/rcS\n" \ | 664 | " ::sysinit:/etc/init.d/rcS\n" \ |
665 | " ::askfirst:/bin/sh\n" \ | 665 | " ::askfirst:/bin/sh\n" \ |
666 | " ::ctrlaltdel:/sbin/reboot\n" \ | ||
667 | " ::shutdown:/sbin/swapoff -a\n" \ | ||
668 | " ::shutdown:/bin/umount -a -r\n" \ | ||
666 | "\n" \ | 669 | "\n" \ |
667 | "if it detects that /dev/console is _not_ a serial console, it will also run:\n" \ | 670 | "if it detects that /dev/console is _not_ a serial console, it will also run:\n" \ |
668 | "\n" \ | 671 | "\n" \ |
669 | " tty2::askfirst:/bin/sh\n" \ | 672 | " tty2::askfirst:/bin/sh\n" \ |
673 | " tty3::askfirst:/bin/sh\n" \ | ||
674 | " tty4::askfirst:/bin/sh\n" \ | ||
670 | "\n" \ | 675 | "\n" \ |
671 | "If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \ | 676 | "If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \ |
672 | "\n" \ | 677 | "\n" \ |
@@ -692,7 +697,7 @@ | |||
692 | " <action>: \n" \ | 697 | " <action>: \n" \ |
693 | "\n" \ | 698 | "\n" \ |
694 | " Valid actions include: sysinit, respawn, askfirst, wait, \n" \ | 699 | " Valid actions include: sysinit, respawn, askfirst, wait, \n" \ |
695 | " once, and ctrlaltdel.\n" \ | 700 | " once, ctrlaltdel, and shutdown.\n" \ |
696 | "\n" \ | 701 | "\n" \ |
697 | " The available actions can be classified into two groups: actions\n" \ | 702 | " The available actions can be classified into two groups: actions\n" \ |
698 | " that are run only once, and actions that are re-run when the specified\n" \ | 703 | " that are run only once, and actions that are re-run when the specified\n" \ |
@@ -706,9 +711,12 @@ | |||
706 | " 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \ | 711 | " 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \ |
707 | " the specified task completes. 'once' actions are asyncronous,\n" \ | 712 | " the specified task completes. 'once' actions are asyncronous,\n" \ |
708 | " therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \ | 713 | " therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \ |
709 | " actions are run immediately before init causes the system to reboot\n" \ | 714 | " actions are run when the system detects that someone on the system\n" \ |
710 | " (unmounting filesystems with a 'ctrlaltdel' action is a very good\n" \ | 715 | " console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \ |
711 | " idea).\n" \ | 716 | " wants to run 'reboot' at this point to cause the system to reboot.\n" \ |
717 | " Finally the 'shutdown' action specifies the actions to taken when\n" \ | ||
718 | " init is told to reboot. Unmounting filesystems and disabling swap\n" \ | ||
719 | " is a very good here\n" \ | ||
712 | "\n" \ | 720 | "\n" \ |
713 | " Run repeatedly actions:\n" \ | 721 | " Run repeatedly actions:\n" \ |
714 | "\n" \ | 722 | "\n" \ |
@@ -759,8 +767,9 @@ | |||
759 | " #::respawn:/sbin/getty 57600 ttyS2\n" \ | 767 | " #::respawn:/sbin/getty 57600 ttyS2\n" \ |
760 | " \n" \ | 768 | " \n" \ |
761 | " # Stuff to do before rebooting\n" \ | 769 | " # Stuff to do before rebooting\n" \ |
762 | " ::ctrlaltdel:/bin/umount -a -r\n" \ | 770 | " ::ctrlaltdel:/sbin/reboot\n" \ |
763 | " ::ctrlaltdel:/sbin/swapoff -a\n" | 771 | " ::shutdown:/bin/umount -a -r\n" \ |
772 | " ::shutdown:/sbin/swapoff -a\n" | ||
764 | 773 | ||
765 | #define insmod_trivial_usage \ | 774 | #define insmod_trivial_usage \ |
766 | "[OPTION]... MODULE [symbol=value]..." | 775 | "[OPTION]... MODULE [symbol=value]..." |
@@ -146,7 +146,8 @@ typedef enum { | |||
146 | ASKFIRST, | 146 | ASKFIRST, |
147 | WAIT, | 147 | WAIT, |
148 | ONCE, | 148 | ONCE, |
149 | CTRLALTDEL | 149 | CTRLALTDEL, |
150 | SHUTDOWN | ||
150 | } initActionEnum; | 151 | } initActionEnum; |
151 | 152 | ||
152 | /* A mapping between "inittab" action name strings and action type codes. */ | 153 | /* A mapping between "inittab" action name strings and action type codes. */ |
@@ -162,6 +163,7 @@ static const struct initActionType actions[] = { | |||
162 | {"wait", WAIT}, | 163 | {"wait", WAIT}, |
163 | {"once", ONCE}, | 164 | {"once", ONCE}, |
164 | {"ctrlaltdel", CTRLALTDEL}, | 165 | {"ctrlaltdel", CTRLALTDEL}, |
166 | {"shutdown", SHUTDOWN}, | ||
165 | {0, 0} | 167 | {0, 0} |
166 | }; | 168 | }; |
167 | 169 | ||
@@ -617,12 +619,12 @@ static void check_memory() | |||
617 | } | 619 | } |
618 | 620 | ||
619 | /* Run all commands to be run right before halt/reboot */ | 621 | /* Run all commands to be run right before halt/reboot */ |
620 | static void run_lastAction(void) | 622 | static void run_actions(initActionEnum action) |
621 | { | 623 | { |
622 | initAction *a, *tmp; | 624 | initAction *a, *tmp; |
623 | for (a = initActionList; a; a = tmp) { | 625 | for (a = initActionList; a; a = tmp) { |
624 | tmp = a->nextPtr; | 626 | tmp = a->nextPtr; |
625 | if (a->action == CTRLALTDEL) { | 627 | if (a->action == action) { |
626 | waitfor(a->process, a->console, FALSE); | 628 | waitfor(a->process, a->console, FALSE); |
627 | delete_initAction(a); | 629 | delete_initAction(a); |
628 | } | 630 | } |
@@ -654,7 +656,7 @@ static void shutdown_system(void) | |||
654 | sleep(1); | 656 | sleep(1); |
655 | 657 | ||
656 | /* run everything to be run at "ctrlaltdel" */ | 658 | /* run everything to be run at "ctrlaltdel" */ |
657 | run_lastAction(); | 659 | run_actions(SHUTDOWN); |
658 | 660 | ||
659 | sync(); | 661 | sync(); |
660 | if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) { | 662 | if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) { |
@@ -696,6 +698,11 @@ static void reboot_signal(int sig) | |||
696 | exit(0); | 698 | exit(0); |
697 | } | 699 | } |
698 | 700 | ||
701 | static void ctrlaltdel_signal(int sig) | ||
702 | { | ||
703 | run_actions(CTRLALTDEL); | ||
704 | } | ||
705 | |||
699 | #endif /* ! DEBUG_INIT */ | 706 | #endif /* ! DEBUG_INIT */ |
700 | 707 | ||
701 | static void new_initAction(initActionEnum action, char *process, char *cons) | 708 | static void new_initAction(initActionEnum action, char *process, char *cons) |
@@ -767,10 +774,12 @@ static void parse_inittab(void) | |||
767 | if (file == NULL) { | 774 | if (file == NULL) { |
768 | /* No inittab file -- set up some default behavior */ | 775 | /* No inittab file -- set up some default behavior */ |
769 | #endif | 776 | #endif |
777 | /* Reboot on Ctrl-Alt-Del */ | ||
778 | new_initAction(CTRLALTDEL, "/sbin/reboot", console); | ||
770 | /* Swapoff on halt/reboot */ | 779 | /* Swapoff on halt/reboot */ |
771 | new_initAction(CTRLALTDEL, "/sbin/swapoff -a", console); | 780 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); |
772 | /* Umount all filesystems on halt/reboot */ | 781 | /* Umount all filesystems on halt/reboot */ |
773 | new_initAction(CTRLALTDEL, "/bin/umount -a -r", console); | 782 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); |
774 | /* Askfirst shell on tty1 */ | 783 | /* Askfirst shell on tty1 */ |
775 | new_initAction(ASKFIRST, SHELL, console); | 784 | new_initAction(ASKFIRST, SHELL, console); |
776 | /* Askfirst shell on tty2 */ | 785 | /* Askfirst shell on tty2 */ |
@@ -883,7 +892,7 @@ extern int init_main(int argc, char **argv) | |||
883 | * clear all of these in run() */ | 892 | * clear all of these in run() */ |
884 | signal(SIGUSR1, halt_signal); | 893 | signal(SIGUSR1, halt_signal); |
885 | signal(SIGUSR2, halt_signal); | 894 | signal(SIGUSR2, halt_signal); |
886 | signal(SIGINT, reboot_signal); | 895 | signal(SIGINT, ctrlaltdel_signal); |
887 | signal(SIGTERM, reboot_signal); | 896 | signal(SIGTERM, reboot_signal); |
888 | 897 | ||
889 | /* Turn off rebooting via CTL-ALT-DEL -- we get a | 898 | /* Turn off rebooting via CTL-ALT-DEL -- we get a |
diff --git a/init/init.c b/init/init.c index 417aadd23..570b8a697 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -146,7 +146,8 @@ typedef enum { | |||
146 | ASKFIRST, | 146 | ASKFIRST, |
147 | WAIT, | 147 | WAIT, |
148 | ONCE, | 148 | ONCE, |
149 | CTRLALTDEL | 149 | CTRLALTDEL, |
150 | SHUTDOWN | ||
150 | } initActionEnum; | 151 | } initActionEnum; |
151 | 152 | ||
152 | /* A mapping between "inittab" action name strings and action type codes. */ | 153 | /* A mapping between "inittab" action name strings and action type codes. */ |
@@ -162,6 +163,7 @@ static const struct initActionType actions[] = { | |||
162 | {"wait", WAIT}, | 163 | {"wait", WAIT}, |
163 | {"once", ONCE}, | 164 | {"once", ONCE}, |
164 | {"ctrlaltdel", CTRLALTDEL}, | 165 | {"ctrlaltdel", CTRLALTDEL}, |
166 | {"shutdown", SHUTDOWN}, | ||
165 | {0, 0} | 167 | {0, 0} |
166 | }; | 168 | }; |
167 | 169 | ||
@@ -617,12 +619,12 @@ static void check_memory() | |||
617 | } | 619 | } |
618 | 620 | ||
619 | /* Run all commands to be run right before halt/reboot */ | 621 | /* Run all commands to be run right before halt/reboot */ |
620 | static void run_lastAction(void) | 622 | static void run_actions(initActionEnum action) |
621 | { | 623 | { |
622 | initAction *a, *tmp; | 624 | initAction *a, *tmp; |
623 | for (a = initActionList; a; a = tmp) { | 625 | for (a = initActionList; a; a = tmp) { |
624 | tmp = a->nextPtr; | 626 | tmp = a->nextPtr; |
625 | if (a->action == CTRLALTDEL) { | 627 | if (a->action == action) { |
626 | waitfor(a->process, a->console, FALSE); | 628 | waitfor(a->process, a->console, FALSE); |
627 | delete_initAction(a); | 629 | delete_initAction(a); |
628 | } | 630 | } |
@@ -654,7 +656,7 @@ static void shutdown_system(void) | |||
654 | sleep(1); | 656 | sleep(1); |
655 | 657 | ||
656 | /* run everything to be run at "ctrlaltdel" */ | 658 | /* run everything to be run at "ctrlaltdel" */ |
657 | run_lastAction(); | 659 | run_actions(SHUTDOWN); |
658 | 660 | ||
659 | sync(); | 661 | sync(); |
660 | if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) { | 662 | if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) { |
@@ -696,6 +698,11 @@ static void reboot_signal(int sig) | |||
696 | exit(0); | 698 | exit(0); |
697 | } | 699 | } |
698 | 700 | ||
701 | static void ctrlaltdel_signal(int sig) | ||
702 | { | ||
703 | run_actions(CTRLALTDEL); | ||
704 | } | ||
705 | |||
699 | #endif /* ! DEBUG_INIT */ | 706 | #endif /* ! DEBUG_INIT */ |
700 | 707 | ||
701 | static void new_initAction(initActionEnum action, char *process, char *cons) | 708 | static void new_initAction(initActionEnum action, char *process, char *cons) |
@@ -767,10 +774,12 @@ static void parse_inittab(void) | |||
767 | if (file == NULL) { | 774 | if (file == NULL) { |
768 | /* No inittab file -- set up some default behavior */ | 775 | /* No inittab file -- set up some default behavior */ |
769 | #endif | 776 | #endif |
777 | /* Reboot on Ctrl-Alt-Del */ | ||
778 | new_initAction(CTRLALTDEL, "/sbin/reboot", console); | ||
770 | /* Swapoff on halt/reboot */ | 779 | /* Swapoff on halt/reboot */ |
771 | new_initAction(CTRLALTDEL, "/sbin/swapoff -a", console); | 780 | new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); |
772 | /* Umount all filesystems on halt/reboot */ | 781 | /* Umount all filesystems on halt/reboot */ |
773 | new_initAction(CTRLALTDEL, "/bin/umount -a -r", console); | 782 | new_initAction(SHUTDOWN, "/bin/umount -a -r", console); |
774 | /* Askfirst shell on tty1 */ | 783 | /* Askfirst shell on tty1 */ |
775 | new_initAction(ASKFIRST, SHELL, console); | 784 | new_initAction(ASKFIRST, SHELL, console); |
776 | /* Askfirst shell on tty2 */ | 785 | /* Askfirst shell on tty2 */ |
@@ -883,7 +892,7 @@ extern int init_main(int argc, char **argv) | |||
883 | * clear all of these in run() */ | 892 | * clear all of these in run() */ |
884 | signal(SIGUSR1, halt_signal); | 893 | signal(SIGUSR1, halt_signal); |
885 | signal(SIGUSR2, halt_signal); | 894 | signal(SIGUSR2, halt_signal); |
886 | signal(SIGINT, reboot_signal); | 895 | signal(SIGINT, ctrlaltdel_signal); |
887 | signal(SIGTERM, reboot_signal); | 896 | signal(SIGTERM, reboot_signal); |
888 | 897 | ||
889 | /* Turn off rebooting via CTL-ALT-DEL -- we get a | 898 | /* Turn off rebooting via CTL-ALT-DEL -- we get a |
diff --git a/init/reboot.c b/init/reboot.c index 3e5f2382c..74d2cf643 100644 --- a/init/reboot.c +++ b/init/reboot.c | |||
@@ -28,9 +28,9 @@ extern int reboot_main(int argc, char **argv) | |||
28 | { | 28 | { |
29 | #ifdef BB_FEATURE_LINUXRC | 29 | #ifdef BB_FEATURE_LINUXRC |
30 | /* don't assume init's pid == 1 */ | 30 | /* don't assume init's pid == 1 */ |
31 | return(kill(*(find_pid_by_name("init")), SIGINT)); | 31 | return(kill(*(find_pid_by_name("init")), SIGTERM)); |
32 | #else | 32 | #else |
33 | return(kill(1, SIGINT)); | 33 | return(kill(1, SIGTERM)); |
34 | #endif | 34 | #endif |
35 | } | 35 | } |
36 | 36 | ||
@@ -28,9 +28,9 @@ extern int reboot_main(int argc, char **argv) | |||
28 | { | 28 | { |
29 | #ifdef BB_FEATURE_LINUXRC | 29 | #ifdef BB_FEATURE_LINUXRC |
30 | /* don't assume init's pid == 1 */ | 30 | /* don't assume init's pid == 1 */ |
31 | return(kill(*(find_pid_by_name("init")), SIGINT)); | 31 | return(kill(*(find_pid_by_name("init")), SIGTERM)); |
32 | #else | 32 | #else |
33 | return(kill(1, SIGINT)); | 33 | return(kill(1, SIGTERM)); |
34 | #endif | 34 | #endif |
35 | } | 35 | } |
36 | 36 | ||
@@ -663,10 +663,15 @@ | |||
663 | "\n" \ | 663 | "\n" \ |
664 | " ::sysinit:/etc/init.d/rcS\n" \ | 664 | " ::sysinit:/etc/init.d/rcS\n" \ |
665 | " ::askfirst:/bin/sh\n" \ | 665 | " ::askfirst:/bin/sh\n" \ |
666 | " ::ctrlaltdel:/sbin/reboot\n" \ | ||
667 | " ::shutdown:/sbin/swapoff -a\n" \ | ||
668 | " ::shutdown:/bin/umount -a -r\n" \ | ||
666 | "\n" \ | 669 | "\n" \ |
667 | "if it detects that /dev/console is _not_ a serial console, it will also run:\n" \ | 670 | "if it detects that /dev/console is _not_ a serial console, it will also run:\n" \ |
668 | "\n" \ | 671 | "\n" \ |
669 | " tty2::askfirst:/bin/sh\n" \ | 672 | " tty2::askfirst:/bin/sh\n" \ |
673 | " tty3::askfirst:/bin/sh\n" \ | ||
674 | " tty4::askfirst:/bin/sh\n" \ | ||
670 | "\n" \ | 675 | "\n" \ |
671 | "If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \ | 676 | "If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \ |
672 | "\n" \ | 677 | "\n" \ |
@@ -692,7 +697,7 @@ | |||
692 | " <action>: \n" \ | 697 | " <action>: \n" \ |
693 | "\n" \ | 698 | "\n" \ |
694 | " Valid actions include: sysinit, respawn, askfirst, wait, \n" \ | 699 | " Valid actions include: sysinit, respawn, askfirst, wait, \n" \ |
695 | " once, and ctrlaltdel.\n" \ | 700 | " once, ctrlaltdel, and shutdown.\n" \ |
696 | "\n" \ | 701 | "\n" \ |
697 | " The available actions can be classified into two groups: actions\n" \ | 702 | " The available actions can be classified into two groups: actions\n" \ |
698 | " that are run only once, and actions that are re-run when the specified\n" \ | 703 | " that are run only once, and actions that are re-run when the specified\n" \ |
@@ -706,9 +711,12 @@ | |||
706 | " 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \ | 711 | " 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \ |
707 | " the specified task completes. 'once' actions are asyncronous,\n" \ | 712 | " the specified task completes. 'once' actions are asyncronous,\n" \ |
708 | " therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \ | 713 | " therefore, init does not wait for them to complete. 'ctrlaltdel'\n" \ |
709 | " actions are run immediately before init causes the system to reboot\n" \ | 714 | " actions are run when the system detects that someone on the system\n" \ |
710 | " (unmounting filesystems with a 'ctrlaltdel' action is a very good\n" \ | 715 | " console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \ |
711 | " idea).\n" \ | 716 | " wants to run 'reboot' at this point to cause the system to reboot.\n" \ |
717 | " Finally the 'shutdown' action specifies the actions to taken when\n" \ | ||
718 | " init is told to reboot. Unmounting filesystems and disabling swap\n" \ | ||
719 | " is a very good here\n" \ | ||
712 | "\n" \ | 720 | "\n" \ |
713 | " Run repeatedly actions:\n" \ | 721 | " Run repeatedly actions:\n" \ |
714 | "\n" \ | 722 | "\n" \ |
@@ -759,8 +767,9 @@ | |||
759 | " #::respawn:/sbin/getty 57600 ttyS2\n" \ | 767 | " #::respawn:/sbin/getty 57600 ttyS2\n" \ |
760 | " \n" \ | 768 | " \n" \ |
761 | " # Stuff to do before rebooting\n" \ | 769 | " # Stuff to do before rebooting\n" \ |
762 | " ::ctrlaltdel:/bin/umount -a -r\n" \ | 770 | " ::ctrlaltdel:/sbin/reboot\n" \ |
763 | " ::ctrlaltdel:/sbin/swapoff -a\n" | 771 | " ::shutdown:/bin/umount -a -r\n" \ |
772 | " ::shutdown:/sbin/swapoff -a\n" | ||
764 | 773 | ||
765 | #define insmod_trivial_usage \ | 774 | #define insmod_trivial_usage \ |
766 | "[OPTION]... MODULE [symbol=value]..." | 775 | "[OPTION]... MODULE [symbol=value]..." |