aboutsummaryrefslogtreecommitdiff
path: root/toys/oneit.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-12-14 02:12:07 -0600
committerRob Landley <rob@landley.net>2008-12-14 02:12:07 -0600
commitcca44505f242e215c7b84cbad0a04d9fc64df899 (patch)
tree57861aac2b0e18f54a8fb338a766b408406eb1e0 /toys/oneit.c
parent7471b5618cb5bee9cc5daaf26cc5d69770b4cb17 (diff)
downloadtoybox-cca44505f242e215c7b84cbad0a04d9fc64df899.tar.gz
Teach oneit to reboot on exit more reliably.
Diffstat (limited to 'toys/oneit.c')
-rw-r--r--toys/oneit.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/toys/oneit.c b/toys/oneit.c
index 341bb080..45935918 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.