Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Mini halt implementation for busybox |
| 4 | * |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 6 | * |
Rob Landley | 2edf526 | 2006-01-22 02:41:51 +0000 | [diff] [blame] | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 10 | #include <signal.h> |
Eric Andersen | 0246222 | 2003-07-22 09:41:39 +0000 | [diff] [blame] | 11 | #include <stdlib.h> |
| 12 | #include <unistd.h> |
| 13 | #include <getopt.h> |
| 14 | #include <sys/reboot.h> |
| 15 | #include "busybox.h" |
Eric Andersen | b01ed65 | 2003-06-27 17:08:15 +0000 | [diff] [blame] | 16 | #include "init_shared.h" |
| 17 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 18 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 19 | extern int halt_main(int argc, char **argv) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 20 | { |
Eric Andersen | 0246222 | 2003-07-22 09:41:39 +0000 | [diff] [blame] | 21 | char *delay; /* delay in seconds before rebooting */ |
| 22 | |
| 23 | if(bb_getopt_ulflags(argc, argv, "d:", &delay)) { |
| 24 | sleep(atoi(delay)); |
| 25 | } |
| 26 | |
Rob Landley | 2edf526 | 2006-01-22 02:41:51 +0000 | [diff] [blame] | 27 | return ENABLE_INIT ? kill(1,SIGUSR1) : bb_shutdown_system(RB_HALT_SYSTEM); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 28 | } |