synchronize history patches with busybox git
[busybox-power] / debian / patches / obselete / upstart-support.patch
1 From 04522f492dc25d650c22e2d4a11296e72fa40e32 Mon Sep 17 00:00:00 2001
2 From: Alexander Shishkin <ext-alexander.shishkin@nokia.com>
3 Date: Wed, 17 Jun 2009 16:01:31 +0300
4 Subject: [PATCH] Call telinit for normal reboot/shutdown.
5
6 Signed-off-by: Alexander Shishkin <ext-alexander.shishkin@nokia.com>
7 ---
8  init/Config.in |   14 ++++++++++++++
9  init/halt.c    |   12 ++++++++++++
10  2 files changed, 26 insertions(+), 0 deletions(-)
11
12 diff --git a/init/Config.in b/init/Config.in
13 index 25f4390..ea91b45 100644
14 --- a/init/Config.in
15 +++ b/init/Config.in
16 @@ -12,6 +12,20 @@ config INIT
17         help
18           init is the first program run when the system boots.
19  
20 +config CALL_TELINIT
21 +       bool "Call telinit on shutdown and reboot"
22 +       help
23 +         What I just said
24 +
25 +config TELINIT_PATH
26 +       string "Path to telinit executable"
27 +       default "/sbin/telinit"
28 +       depends on CALL_TELINIT
29 +       help
30 +         When busybox halt and friends have to call external telinit
31 +         to facilitate proper shutdown, this path is to be used when
32 +         locating telinit executable.
33 +
34  config DEBUG_INIT
35         bool "Debugging aid"
36         default n
37 diff --git a/init/halt.c b/init/halt.c
38 index c14f0f2..b877be1 100644
39 --- a/init/halt.c
40 +++ b/init/halt.c
41 @@ -84,6 +84,18 @@ RB_AUTOBOOT
42                 }
43                 if (rc)
44                         rc = kill(1, signals[which]);
45 +       } else if (ENABLE_CALL_TELINIT && !(flags & 4)) {
46 +               /* runlevels:
47 +                * 0 == shutdown
48 +                * 6 == reboot */
49 +               const char *telinit_argv[] = {
50 +                       "telinit",
51 +                       which == 2 ? "6" : "0",
52 +                       NULL
53 +               };
54 +
55 +               forkexit_or_rexec();
56 +               execve(CONFIG_TELINIT_PATH, telinit_argv, environ);
57         } else
58                 rc = reboot(magic[which]);
59  
60 -- 
61 1.6.3.1
62