[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [BusyBox] bug#1107: possible solution
From: Matt Kraai <kraai () alumni ! carnegiemellon ! edu>
Date: 2001-03-28 5:49:55
[Download RAW message or body]
Howdy,
Working backwards...
The ls problem is fixed in later releases.
The attached patch may fix the first problem, which reports that
pressing ctrl-alt-del shouldn't necessarily reboot the machine.
Basically, it follows the suggestion of the submitter and calls
reboot. It also does the work to make this necessary.
Unfortunately, I don't have a system on which to test it. So if
someone out there in TV land could please give this a try and
ensure that it works, I'd appreciate it. I'll submit a doc patch
if this turns out to be acceptable.
Matt
Index: init.c
===================================================================
RCS file: /var/cvs/busybox/init.c,v
retrieving revision 1.129
diff -u -r1.129 init.c
--- init.c 2001/03/21 07:34:26 1.129
+++ init.c 2001/03/28 05:49:52
@@ -146,7 +146,8 @@
ASKFIRST,
WAIT,
ONCE,
- CTRLALTDEL
+ CTRLALTDEL,
+ SHUTDOWN
} initActionEnum;
/* A mapping between "inittab" action name strings and action type codes. */
@@ -162,6 +163,7 @@
{"wait", WAIT},
{"once", ONCE},
{"ctrlaltdel", CTRLALTDEL},
+ {"shutdown", SHUTDOWN},
{0, 0}
};
@@ -617,12 +619,12 @@
}
/* Run all commands to be run right before halt/reboot */
-static void run_lastAction(void)
+static void run_actions(initActionEnum action)
{
initAction *a, *tmp;
for (a = initActionList; a; a = tmp) {
tmp = a->nextPtr;
- if (a->action == CTRLALTDEL) {
+ if (a->action == action) {
waitfor(a->process, a->console, FALSE);
delete_initAction(a);
}
@@ -654,7 +656,7 @@
sleep(1);
/* run everything to be run at "ctrlaltdel" */
- run_lastAction();
+ run_actions(SHUTDOWN);
sync();
if (kernelVersion > 0 && kernelVersion <= KERNEL_VERSION(2,2,11)) {
@@ -696,6 +698,11 @@
exit(0);
}
+static void ctrlaltdel_signal(int sig)
+{
+ run_actions(CTRLALTDEL);
+}
+
#endif /* ! DEBUG_INIT */
static void new_initAction(initActionEnum action, char *process, char *cons)
@@ -767,10 +774,12 @@
if (file == NULL) {
/* No inittab file -- set up some default behavior */
#endif
+ /* Reboot on Ctrl-Alt-Del */
+ new_initAction(CTRLALTDEL, "/sbin/reboot", console);
/* Swapoff on halt/reboot */
- new_initAction(CTRLALTDEL, "/sbin/swapoff -a", console);
+ new_initAction(SHUTDOWN, "/sbin/swapoff -a", console);
/* Umount all filesystems on halt/reboot */
- new_initAction(CTRLALTDEL, "/bin/umount -a -r", console);
+ new_initAction(SHUTDOWN, "/bin/umount -a -r", console);
/* Askfirst shell on tty1 */
new_initAction(ASKFIRST, SHELL, console);
/* Askfirst shell on tty2 */
@@ -883,7 +892,7 @@
* clear all of these in run() */
signal(SIGUSR1, halt_signal);
signal(SIGUSR2, halt_signal);
- signal(SIGINT, reboot_signal);
+ signal(SIGINT, ctrlaltdel_signal);
signal(SIGTERM, reboot_signal);
/* Turn off rebooting via CTL-ALT-DEL -- we get a
Index: reboot.c
===================================================================
RCS file: /var/cvs/busybox/reboot.c,v
retrieving revision 1.16
diff -u -r1.16 reboot.c
--- reboot.c 2000/12/07 19:56:48 1.16
+++ reboot.c 2001/03/28 05:49:52
@@ -28,9 +28,9 @@
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGINT));
+ return(kill(*(find_pid_by_name("init")), SIGTERM));
#else
- return(kill(1, SIGINT));
+ return(kill(1, SIGTERM));
#endif
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic