diff options
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -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 |