[BusyBox] System doesn't halt/reboot

Iwasa Kazmi kzmi at ca2.so-net.ne.jp
Sat Oct 12 14:10:03 UTC 2002


Hi,

On Fri, 11 Oct 2002 10:57:51 +0100
"John Hall" <john.hall at optionexist.co.uk> wrote:

> I'm using busybox 0.60.4 on a Strongarm running Linux 2.4.18-rmk7. My problem is that busybox init hangs during halt. The code in question is in shutdown_system():
> 
>     message(CONSOLE|LOG, "\n\rThe system is going down NOW !!\n");
>     sync();
> 
>     /* Send signals to every process _except_ pid 1 */
>     message(CONSOLE|LOG, "\rSending SIGTERM to all processes.\n");
>     kill(-1, SIGTERM);
>     sleep(1);			// <------- HANGS ON THIS LINE
>     sync();
> 
>     message(CONSOLE|LOG, "\rSending SIGKILL to all processes.\n");
>     kill(-1, SIGKILL);
>     sleep(1);
> 

I'm not sure if this patch solves your problem, but...
waitpid() needs ECHILD check. See patch below.
(another waitpid() already have ECHILD check)

BTW, run_actions() is not reentrant.  Deleting item from init_action_list
is not safe.  run_actions() should be reentrant because it is called from
signal handlers.
I think that adding "already-done" bit is better method than deleting action.
However, it is NOT serious matter.  Such critical case is only in
SIGINT(run CTRLALTDEL) -> SIGTERM(run SHUTDOWN) sequence, and it will
not complete its sequence due to the power-down :-)

-- 
Iwasa Kazmi


--- init.c.orig	2002-09-16 15:55:12.000000000 +0900
+++ init.c	2002-10-10 01:12:48.000000000 +0900
@@ -541,8 +541,10 @@
 				signal(SIGCHLD, SIG_DFL);
 
 				/* Wait for child to exit */
-				while ((tmp_pid = waitpid(pid, &junk, 0)) != pid)
-					;
+				while ((tmp_pid = waitpid(pid, &junk, 0)) != pid) {
+					if (tmp_pid < 0 && errno == ECHILD)
+						break;
+				}
 
 				/* See if stealing the controlling tty back is necessary */
 				pgrp = tcgetpgrp(0);



More information about the busybox mailing list