Skip to content

Commit d88bafb

Browse files
committed
patches: silence BusyBox init when used in container builds
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent eda9957 commit d88bafb

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

configs/curios-nftables_amd64_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ BR2_CCACHE=y
66
BR2_CCACHE_DIR="${BR2_EXTERNAL_CURIOS_PATH}/.ccache"
77
BR2_OPTIMIZE_S=y
88
BR2_STATIC_LIBS=y
9+
BR2_GLOBAL_PATCH_DIR="${BR2_EXTERNAL_CURIOS_PATH}/patches"
910
BR2_TARGET_GENERIC_HOSTNAME="curiOS"
1011
BR2_TARGET_GENERIC_ISSUE="Welcome to curiOS"
1112
# BR2_TARGET_ENABLE_ROOT_LOGIN is not set

configs/curios-nftables_arm64_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ BR2_CCACHE=y
77
BR2_CCACHE_DIR="${BR2_EXTERNAL_CURIOS_PATH}/.ccache"
88
BR2_OPTIMIZE_S=y
99
BR2_STATIC_LIBS=y
10+
BR2_GLOBAL_PATCH_DIR="${BR2_EXTERNAL_CURIOS_PATH}/patches"
1011
BR2_TARGET_GENERIC_HOSTNAME="curiOS"
1112
BR2_TARGET_GENERIC_ISSUE="Welcome to curiOS"
1213
# BR2_TARGET_ENABLE_ROOT_LOGIN is not set
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
From 09e4f9a964a9f96c09d7ef53d07917dcc4bdf5d7 Mon Sep 17 00:00:00 2001
2+
From: Joachim Wiberg <troglobit@gmail.com>
3+
Date: Sat, 21 Jun 2025 03:12:38 +0200
4+
Subject: [PATCH] init: simplify for container usage
5+
Organization: Wires
6+
7+
All logging of containers go through stderr to the host's syslog, so we
8+
do not need any console line cleanup, sleeps for output propagation, or
9+
extra warnings.
10+
11+
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
12+
---
13+
init/init.c | 21 ++++-----------------
14+
1 file changed, 4 insertions(+), 17 deletions(-)
15+
16+
diff --git a/init/init.c b/init/init.c
17+
index 1e1ce833d..d85494450 100644
18+
--- a/init/init.c
19+
+++ b/init/init.c
20+
@@ -237,9 +237,8 @@ static void message(int where, const char *fmt, ...)
21+
unsigned l;
22+
char msg[128];
23+
24+
- msg[0] = '\r';
25+
va_start(arguments, fmt);
26+
- l = 1 + vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments);
27+
+ l = vsnprintf(msg, sizeof(msg) - 2, fmt, arguments);
28+
if (l > sizeof(msg) - 2)
29+
l = sizeof(msg) - 2;
30+
va_end(arguments);
31+
@@ -735,9 +734,6 @@ static void pause_and_low_level_reboot(unsigned magic)
32+
{
33+
pid_t pid;
34+
35+
- /* Allow time for last message to reach serial console, etc */
36+
- sleep1();
37+
-
38+
/* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS)
39+
* in linux/kernel/sys.c, which can cause the machine to panic when
40+
* the init process exits... */
41+
@@ -751,7 +747,6 @@ static void pause_and_low_level_reboot(unsigned magic)
42+
* we would eternally sleep here - not what we want.
43+
*/
44+
waitpid(pid, NULL, 0);
45+
- sleep1(); /* paranoia */
46+
_exit_SUCCESS();
47+
}
48+
49+
@@ -766,14 +761,11 @@ static void run_shutdown_and_kill_processes(void)
50+
51+
/* Send signals to every process _except_ pid 1 */
52+
kill(-1, SIGTERM);
53+
- message(L_CONSOLE, "Sent SIG%s to all processes", "TERM");
54+
sync();
55+
sleep1();
56+
57+
kill(-1, SIGKILL);
58+
- message(L_CONSOLE, "Sent SIG%s to all processes", "KILL");
59+
sync();
60+
- /*sleep1(); - callers take care about making a pause */
61+
}
62+
63+
/* Signal handling by init:
64+
@@ -810,7 +802,6 @@ static void run_shutdown_and_kill_processes(void)
65+
static void halt_reboot_pwoff(int sig) NORETURN;
66+
static void halt_reboot_pwoff(int sig)
67+
{
68+
- const char *m;
69+
unsigned rb;
70+
71+
/* We may call run() and it unmasks signals,
72+
@@ -823,16 +814,12 @@ static void halt_reboot_pwoff(int sig)
73+
74+
run_shutdown_and_kill_processes();
75+
76+
- m = "halt";
77+
rb = RB_HALT_SYSTEM;
78+
- if (sig == SIGTERM) {
79+
- m = "reboot";
80+
+ if (sig == SIGTERM)
81+
rb = RB_AUTOBOOT;
82+
- } else if (sig == SIGUSR2) {
83+
- m = "poweroff";
84+
+ else if (sig == SIGUSR2)
85+
rb = RB_POWER_OFF;
86+
- }
87+
- message(L_CONSOLE, "Requesting system %s", m);
88+
+
89+
pause_and_low_level_reboot(rb);
90+
/* not reached */
91+
}
92+
--
93+
2.43.0
94+

0 commit comments

Comments
 (0)