init: hopefully fix "rebooting" in containers
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 22 Sep 2018 17:30:40 +0000 (19:30 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 22 Sep 2018 17:30:40 +0000 (19:30 +0200)
function                                             old     new   delta
pause_and_low_level_reboot                            48      57      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
init/init.c

index 6439e2bcd8627a739bbb4fa0f863716f082763b5..fde35f6b653fa4527ebc0132923829651dbff6c8 100644 (file)
@@ -752,8 +752,13 @@ static void pause_and_low_level_reboot(unsigned magic)
                reboot(magic);
                _exit(EXIT_SUCCESS);
        }
-       while (1)
-               sleep(1);
+       /* Used to have "while (1) sleep(1)" here.
+        * However, in containers reboot() call is ignored, and with that loop
+        * we would eternally sleep here - not what we want.
+        */
+       waitpid(pid, NULL, 0);
+       sleep(1); /* paranoia */
+       _exit(EXIT_SUCCESS);
 }
 
 static void run_shutdown_and_kill_processes(void)