diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-07-22 09:41:39 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-07-22 09:41:39 +0000 |
commit | 932734db6ba4f5aa3830833f70aa99e03a453525 (patch) | |
tree | a254319c3697e8f1493373cd1148a6aa1e74a6a6 /init/poweroff.c | |
parent | fa8cf20631cf02ae3e6b0db95a494261df1aee27 (diff) | |
download | busybox-w32-932734db6ba4f5aa3830833f70aa99e03a453525.tar.gz busybox-w32-932734db6ba4f5aa3830833f70aa99e03a453525.tar.bz2 busybox-w32-932734db6ba4f5aa3830833f70aa99e03a453525.zip |
Support reboot, halt, and poweroff independent of busybox init.
Simplify and fixup some logic.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@7091 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'init/poweroff.c')
-rw-r--r-- | init/poweroff.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/init/poweroff.c b/init/poweroff.c index d630aa6c2..e5d45dfa0 100644 --- a/init/poweroff.c +++ b/init/poweroff.c | |||
@@ -2,7 +2,6 @@ | |||
2 | /* | 2 | /* |
3 | * Mini poweroff implementation for busybox | 3 | * Mini poweroff 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,10 +20,37 @@ | |||
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" | ||
29 | #include "init_shared.h" | ||
30 | |||
26 | 31 | ||
27 | extern int poweroff_main(int argc, char **argv) | 32 | extern int poweroff_main(int argc, char **argv) |
28 | { | 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_POWER_OFF | ||
42 | #define RB_POWER_OFF 0x4321fedc | ||
43 | #endif | ||
44 | return(bb_shutdown_system(RB_POWER_OFF)); | ||
45 | #else | ||
29 | return kill_init(SIGUSR2); | 46 | return kill_init(SIGUSR2); |
47 | #endif | ||
30 | } | 48 | } |
49 | |||
50 | /* | ||
51 | Local Variables: | ||
52 | c-file-style: "linux" | ||
53 | c-basic-offset: 4 | ||
54 | tab-width: 4 | ||
55 | End: | ||
56 | */ | ||