diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-07-22 09:41:39 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-07-22 09:41:39 +0000 |
commit | 0246222351a8787e2e726c2526d795440893859c (patch) | |
tree | a254319c3697e8f1493373cd1148a6aa1e74a6a6 /init/halt.c | |
parent | 85e5e72bc1acd9d58c11bde6e14c8270cd9f169f (diff) | |
download | busybox-w32-0246222351a8787e2e726c2526d795440893859c.tar.gz busybox-w32-0246222351a8787e2e726c2526d795440893859c.tar.bz2 busybox-w32-0246222351a8787e2e726c2526d795440893859c.zip |
Support reboot, halt, and poweroff independent of busybox init.
Simplify and fixup some logic.
-Erik
Diffstat (limited to 'init/halt.c')
-rw-r--r-- | init/halt.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/init/halt.c b/init/halt.c index 10f16c75d..decdaeafd 100644 --- a/init/halt.c +++ b/init/halt.c | |||
@@ -2,7 +2,6 @@ | |||
2 | /* | 2 | /* |
3 | * Mini halt implementation for busybox | 3 | * Mini halt implementation for busybox |
4 | * | 4 | * |
5 | * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>. | ||
6 | * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> |
7 | * | 6 | * |
8 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -21,12 +20,29 @@ | |||
21 | * | 20 | * |
22 | */ | 21 | */ |
23 | 22 | ||
24 | #include "busybox.h" | ||
25 | #include <signal.h> | 23 | #include <signal.h> |
24 | #include <stdlib.h> | ||
25 | #include <unistd.h> | ||
26 | #include <getopt.h> | ||
27 | #include <sys/reboot.h> | ||
28 | #include "busybox.h" | ||
26 | #include "init_shared.h" | 29 | #include "init_shared.h" |
27 | 30 | ||
28 | 31 | ||
29 | extern int halt_main(int argc, char **argv) | 32 | extern int halt_main(int argc, char **argv) |
30 | { | 33 | { |
34 | char *delay; /* delay in seconds before rebooting */ | ||
35 | |||
36 | if(bb_getopt_ulflags(argc, argv, "d:", &delay)) { | ||
37 | sleep(atoi(delay)); | ||
38 | } | ||
39 | |||
40 | #ifndef CONFIG_INIT | ||
41 | #ifndef RB_HALT_SYSTEM | ||
42 | #define RB_HALT_SYSTEM 0xcdef0123 | ||
43 | #endif | ||
44 | return(bb_shutdown_system(RB_HALT_SYSTEM)); | ||
45 | #else | ||
31 | return kill_init(SIGUSR1); | 46 | return kill_init(SIGUSR1); |
47 | #endif | ||
32 | } | 48 | } |