From: Rob Landley Date: Sun, 14 Dec 2008 08:12:07 +0000 (-0600) Subject: Teach oneit to reboot on exit more reliably. X-Git-Tag: 0.0.8~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cca44505f242e215c7b84cbad0a04d9fc64df899;p=platform%2Fupstream%2Ftoybox.git Teach oneit to reboot on exit more reliably. --- diff --git a/toys/oneit.c b/toys/oneit.c index 341bb08..4593591 100644 --- a/toys/oneit.c +++ b/toys/oneit.c @@ -58,7 +58,12 @@ void oneit_main(void) // pid 1 just reaps zombies until it gets its child, then halts the system. while (pid!=wait(&i)); sync(); - reboot(toys.optflags ? RB_POWER_OFF : RB_AUTOBOOT); + + // PID 1 can't call reboot() because it kills the task that calls it, + // which causes the kernel to panic before the actual reboot happens. + if (!vfork()) reboot((toys.optflags&1) ? RB_POWER_OFF : RB_AUTOBOOT); + sleep(5); + _exit(1); } // Redirect stdio to /dev/tty0, with new session ID, so ctrl-c works.