[uClibc]Re: [BusyBox] shutdown
Martin Sieper
msi at ngi-box.de
Sun Apr 7 09:29:08 UTC 2002
Hello Ramya,
on Saturday 6 April 2002 at 19:38:08 -0800 you wrote:
>
> I tried halt and poweroff and I get the messges
>
> "The system has halted. Press cntrl+alt+del or turn
> off power
> Stopping all md devices
> System Halted
> Kernel Panic : Attempted to kill init"
>
> Why do I get the kernel panic message?
In the past I had the same problem. To solve this take a look on my
attached patch. This patch work for me very fine.
-Martin
-------------- next part --------------
--- init.c.orig Tue Nov 20 06:43:28 2001
+++ init.c Thu Feb 14 14:33:04 2002
@@ -660,12 +660,12 @@
sync();
/* Send signals to every process _except_ pid 1 */
- message(CONSOLE|LOG, "Sending SIGTERM to all processes.\n");
+ message(CONSOLE|LOG, "\rSending SIGTERM to all processes.\n");
kill(-1, SIGTERM);
sleep(1);
sync();
- message(CONSOLE|LOG, "Sending SIGKILL to all processes.\n");
+ message(CONSOLE|LOG, "\rSending SIGKILL to all processes.\n");
kill(-1, SIGKILL);
sleep(1);
@@ -682,6 +682,8 @@
static void halt_signal(int sig)
{
+ int pid;
+
shutdown_system();
message(CONSOLE|LOG,
#if #cpu(s390)
@@ -689,7 +691,7 @@
"The system is halted. You may reboot now.\n",
#else
/* secondConsole is NULL for a serial console */
- "The system is halted. Press %s or turn off power\n",
+ "\rThe system is halted. Press %s or turn off power\n",
(secondConsole == NULL)? "Reset" : "CTRL-ALT-DEL"
#endif
);
@@ -698,12 +700,27 @@
/* allow time for last message to reach serial console */
sleep(2);
- if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0))
- init_reboot(RB_POWER_OFF);
- else
- init_reboot(RB_HALT_SYSTEM);
-
- loop_forever();
+ if (sig == SIGUSR2 && kernelVersion >= KERNEL_VERSION(2,2,0)) {
+ pid = fork();
+ if (pid < 0) {
+ fprintf(stderr, "init: fork() error\n");
+ } else if (pid == 0) {
+ setsid();
+ init_reboot(RB_POWER_OFF);
+ } else if (pid > 0) {
+ loop_forever();
+ }
+ } else {
+ pid = fork();
+ if (pid < 0) {
+ fprintf(stderr, "init: fork() error\n");
+ } else if (pid == 0) {
+ setsid();
+ init_reboot(RB_HALT_SYSTEM);
+ } else if (pid > 0) {
+ loop_forever();
+ }
+ }
}
static void reboot_signal(int sig)
More information about the uClibc
mailing list