blob: 5508f0be917fe2db5e784ee5171c2bc2b7c182b6 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersenc4996011999-10-20 22:08:37 +00002/*
3 * Mini reboot implementation for busybox
4 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersenc4996011999-10-20 22:08:37 +00006 *
Rob Landley2edf5262006-01-22 02:41:51 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersenc4996011999-10-20 22:08:37 +00008 */
9
Eric Andersencc8ed391999-10-05 16:24:54 +000010#include <signal.h>
Eric Andersen34fd00a2002-09-17 08:40:12 +000011#include <stdlib.h>
12#include <unistd.h>
13#include <getopt.h>
Eric Andersen85e5e722003-07-22 08:56:55 +000014#include <sys/reboot.h>
Glenn L McGrath4e05b9b2002-12-07 23:14:40 +000015#include "busybox.h"
Eric Andersenb01ed652003-06-27 17:08:15 +000016#include "init_shared.h"
17
Glenn L McGrath4e05b9b2002-12-07 23:14:40 +000018
Erik Andersene49d5ec2000-02-08 19:58:47 +000019extern int reboot_main(int argc, char **argv)
Eric Andersencc8ed391999-10-05 16:24:54 +000020{
Eric Andersenb01ed652003-06-27 17:08:15 +000021 char *delay; /* delay in seconds before rebooting */
Eric Andersen34fd00a2002-09-17 08:40:12 +000022
Eric Andersenb01ed652003-06-27 17:08:15 +000023 if(bb_getopt_ulflags(argc, argv, "d:", &delay)) {
24 sleep(atoi(delay));
Eric Andersen34fd00a2002-09-17 08:40:12 +000025 }
26
Rob Landley2edf5262006-01-22 02:41:51 +000027 return ENABLE_INIT ? kill(1,SIGTERM) : bb_shutdown_system(RB_AUTOBOOT);
Eric Andersencc8ed391999-10-05 16:24:54 +000028}