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 reboot 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 | 34fd00a | 2002-09-17 08:40:12 +0000 | [diff] [blame] | 11 | #include <stdlib.h> |
12 | #include <unistd.h> | ||||
13 | #include <getopt.h> | ||||
Eric Andersen | 85e5e72 | 2003-07-22 08:56:55 +0000 | [diff] [blame] | 14 | #include <sys/reboot.h> |
Glenn L McGrath | 4e05b9b | 2002-12-07 23:14:40 +0000 | [diff] [blame] | 15 | #include "busybox.h" |
Eric Andersen | b01ed65 | 2003-06-27 17:08:15 +0000 | [diff] [blame] | 16 | #include "init_shared.h" |
17 | |||||
Glenn L McGrath | 4e05b9b | 2002-12-07 23:14:40 +0000 | [diff] [blame] | 18 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 19 | extern int reboot_main(int argc, char **argv) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 20 | { |
Eric Andersen | b01ed65 | 2003-06-27 17:08:15 +0000 | [diff] [blame] | 21 | char *delay; /* delay in seconds before rebooting */ |
Eric Andersen | 34fd00a | 2002-09-17 08:40:12 +0000 | [diff] [blame] | 22 | |
Eric Andersen | b01ed65 | 2003-06-27 17:08:15 +0000 | [diff] [blame] | 23 | if(bb_getopt_ulflags(argc, argv, "d:", &delay)) { |
24 | sleep(atoi(delay)); | ||||
Eric Andersen | 34fd00a | 2002-09-17 08:40:12 +0000 | [diff] [blame] | 25 | } |
26 | |||||
Rob Landley | 2edf526 | 2006-01-22 02:41:51 +0000 | [diff] [blame] | 27 | return ENABLE_INIT ? kill(1,SIGTERM) : bb_shutdown_system(RB_AUTOBOOT); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 28 | } |