wok view busybox/stuff/busybox-1.31-shutdown.u @ rev 23743

updated xcb-proto, libxcb and libxcb-dev (1.13 -> 1.14)
author Hans-G?nter Theisgen
date Fri May 01 13:39:34 2020 +0100 (2020-05-01)
parents
children
line source
1 --- busybox-1.31/init/halt.c
2 +++ busybox-1.31/init/halt.c
3 @@ -59,6 +59,7 @@
4 // APPLET_ODDNAME:name main location suid_type help
5 //applet:IF_POWEROFF(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff))
6 //applet:IF_REBOOT( APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot))
7 +//applet:IF_REBOOT( APPLET_ODDNAME(shutdown, halt, BB_DIR_SBIN, BB_SUID_DROP, shutdown))
9 //kbuild:lib-$(CONFIG_HALT) += halt.o
10 //kbuild:lib-$(CONFIG_POWEROFF) += halt.o
11 @@ -90,6 +91,15 @@
12 //usage: "\n -d SEC Delay interval"
13 //usage: "\n -n Do not sync"
14 //usage: "\n -f Force (don't go through init)"
15 +//usage:
16 +//usage:#define shutdown_trivial_usage
17 +//usage: "[-rhHP]"
18 +//usage:#define shutdown_full_usage "\n\n"
19 +//usage: "Bring the system down\n"
20 +//usage: "\n -r Do reboot"
21 +//usage: "\n -h Do poweroff"
22 +//usage: "\n -H Do halt"
23 +//usage: "\n -P Do poweroff"
25 #include "libbb.h"
26 #include "reboot.h"
27 @@ -164,6 +174,7 @@
28 int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
29 int halt_main(int argc UNUSED_PARAM, char **argv)
30 {
31 + enum { HALT=0, POWEROFF=1, REBOOT=2, SHUTDOWN=3 };
32 static const int magic[] = {
33 RB_HALT_SYSTEM,
34 RB_POWER_OFF,
35 @@ -184,15 +195,26 @@
36 if (!ENABLE_HALT && !ENABLE_POWEROFF && ENABLE_REBOOT)
37 which = 2;
38 else
39 - for (which = 0; "hpr"[which] != applet_name[0]; which++)
40 + for (which = 0; "hprs"[which] != applet_name[0]; which++)
41 continue;
43 + if (which == SHUTDOWN) {
44 + which = REBOOT;
45 + switch (getopt32(argv, "rhPH")) {
46 + case 2:
47 + case 4: which = POWEROFF; break;
48 + case 8: which = HALT;
49 + }
50 + flags = 0;
51 + }
52 + else {
53 /* Parse and handle arguments */
54 /* We support -w even if !ENABLE_FEATURE_WTMP,
55 * in order to not break scripts.
56 * -i (shut down network interfaces) is ignored.
57 */
58 flags = getopt32(argv, "d:+nfwi", &delay);
59 + }
61 sleep(delay);