[PATCH] init.c, halt command not working

Denys Vlasenko vda.linux at googlemail.com
Mon Mar 31 02:15:07 UTC 2008


On Sunday 30 March 2008 22:46, Harald Küthe wrote:
> Hello list,
> 
> (at least) the halt command is no longer working on our system (ppc32, 
> linux-2.4.36)
> Following patch makes it work again.



> --- busybox-1.10.0-orig/init/init.c    2008-03-22 02:31:51.000000000 +0100
> +++ busybox-1.10.0/init/init.c    2008-03-30 22:22:02.000000000 +0200
> @@ -372,7 +372,7 @@
>      sigemptyset(&nmask);
>      sigaddset(&nmask, SIGCHLD);
>      sigprocmask(SIG_BLOCK, &nmask, &omask);
> -    pid = vfork();
> +    pid = BB_MMU ? fork() : vfork();
>      sigprocmask(SIG_SETMASK, &omask, NULL);
>  
>      if (pid < 0)

Did you debug the reason where it broke if vfork is used?

The sequence of events is:
SIGUSR1 is received
halt_reboot_pwoff(SIGUSR1) calls
 kill_all_processes() calls
  run_actions(SHUTDOWN):
                        if (a->action_type & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) {
                                waitfor(run(a));
                                delete_init_action(a);
run(a) vforks... and this is somehow doesn't work very well

Quick test:
If you simply remove run_actions(SHUTDOWN) in kill_all_processes(),
does it work now?

> @@ -529,7 +529,7 @@
>      /* We have to fork here, since the kernel calls do_exit(0) in
>       * linux/kernel/sys.c, which can cause the machine to panic when
>       * the init process is killed.... */
> -    pid = vfork();
> +    pid = BB_MMU ? fork() : vfork();
>      if (pid == 0) { /* child */
>          reboot(magic);
>          _exit(0);

Does it work without this change? It should...
--
vda



More information about the busybox mailing list