blob: 89efdd64a2cbb8199fe80842ca959274406e2892 [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 halt 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 Andersen02462222003-07-22 09:41:39 +000011#include <stdlib.h>
12#include <unistd.h>
13#include <getopt.h>
14#include <sys/reboot.h>
15#include "busybox.h"
Eric Andersenb01ed652003-06-27 17:08:15 +000016#include "init_shared.h"
17
Eric Andersencc8ed391999-10-05 16:24:54 +000018
Erik Andersene49d5ec2000-02-08 19:58:47 +000019extern int halt_main(int argc, char **argv)
Eric Andersencc8ed391999-10-05 16:24:54 +000020{
Eric Andersen02462222003-07-22 09:41:39 +000021 char *delay; /* delay in seconds before rebooting */
22
23 if(bb_getopt_ulflags(argc, argv, "d:", &delay)) {
24 sleep(atoi(delay));
25 }
26
Rob Landley2edf5262006-01-22 02:41:51 +000027 return ENABLE_INIT ? kill(1,SIGUSR1) : bb_shutdown_system(RB_HALT_SYSTEM);
Eric Andersencc8ed391999-10-05 16:24:54 +000028}