1 Star 0 Fork 48

fe.zhang/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
庞庆 提交于 2022-04-19 15:08 . Add optimized patches
From dffb92b5520a4b539f0466d4161fcaacc6ba5ba8 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 19 Apr 2022 11:34:27 +0800
Subject: [PATCH] main: don't freeze PID 1 in containers, exit with
---
src/core/main.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/core/main.c b/src/core/main.c
index d897155..0aec5d1 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -139,7 +139,13 @@ static NUMAPolicy arg_numa_policy;
static int parse_configuration(const struct rlimit *saved_rlimit_nofile,
const struct rlimit *saved_rlimit_memlock);
-_noreturn_ static void freeze_or_reboot(void) {
+_noreturn_ static void freeze_or_exit_or_reboot(void) {
+ /* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the
+ * container manager, and thus inform it that something went wrong. */
+ if (detect_container() > 0) {
+ log_emergency("Exiting PID 1...");
+ exit(EXIT_EXCEPTION);
+ }
if (arg_crash_reboot) {
log_notice("Rebooting in 10s...");
@@ -247,7 +253,7 @@ _noreturn_ static void crash(int sig) {
}
}
- freeze_or_reboot();
+ freeze_or_exit_or_reboot();
}
static void install_crash_handler(void) {
@@ -2664,9 +2670,9 @@ finish:
if (error_message)
manager_status_printf(NULL, STATUS_TYPE_EMERGENCY,
ANSI_HIGHLIGHT_RED "!!!!!!" ANSI_NORMAL,
- "%s, freezing.", error_message);
- freeze_or_reboot();
+ "%s.", error_message);
+ freeze_or_exit_or_reboot();
}
reset_arguments();
return retval;
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fe_zhang/systemd.git
git@gitee.com:fe_zhang/systemd.git
fe_zhang
systemd
systemd
a8

搜索帮助