89efdd64a2cbb8199fe80842ca959274406e2892
[oweals/busybox.git] / init / halt.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Mini halt implementation for busybox
4  *
5  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6  *
7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8  */
9
10 #include <signal.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <getopt.h>
14 #include <sys/reboot.h>
15 #include "busybox.h"
16 #include "init_shared.h"
17
18
19 extern int halt_main(int argc, char **argv)
20 {
21         char *delay; /* delay in seconds before rebooting */
22
23         if(bb_getopt_ulflags(argc, argv, "d:", &delay)) {
24                 sleep(atoi(delay));
25         }
26
27         return ENABLE_INIT ? kill(1,SIGUSR1) : bb_shutdown_system(RB_HALT_SYSTEM);
28 }