From 1d8e10f6ea815e027e9783f0ecc1e0d0e1353e59 Mon Sep 17 00:00:00 2001 From: cheng_jinsong Date: Mon, 21 Nov 2022 17:29:22 +0800 Subject: [PATCH] parse init cfg from GetCfgFiles Signed-off-by: cheng_jinsong --- services/init/include/init.h | 2 ++ services/init/init_config.c | 3 +-- services/init/lite/init.c | 6 ++++++ services/init/standard/init.c | 13 +++++++++++++ services/init/standard/init_signal_handler.c | 8 +++++--- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/services/init/include/init.h b/services/init/include/init.h index 0a5fe4b3..2268363c 100644 --- a/services/init/include/init.h +++ b/services/init/include/init.h @@ -47,6 +47,8 @@ void SystemConfig(void); void SystemRun(void); void SystemExecuteRcs(void); +void ParseInitCfgByPriority(void); +int ParseInitCfg(const char *configFile, void *context); void ReadConfig(void); void SignalInit(void); diff --git a/services/init/init_config.c b/services/init/init_config.c index bc1dcd69..f859dafb 100644 --- a/services/init/init_config.c +++ b/services/init/init_config.c @@ -103,8 +103,7 @@ void ReadConfig(void) ReadFileInDir(OTHER_CHARGE_PATH, ".cfg", ParseInitCfg, NULL); } else if (InUpdaterMode() == 0) { ParseInitCfg(INIT_CONFIGURATION_FILE, NULL); - ReadFileInDir(OTHER_CFG_PATH, ".cfg", ParseInitCfg, NULL); - ReadFileInDir("/vendor/etc/init", ".cfg", ParseInitCfg, NULL); + ParseInitCfgByPriority(); } else { ReadFileInDir("/etc", ".cfg", ParseInitCfg, NULL); } diff --git a/services/init/lite/init.c b/services/init/lite/init.c index 2719496b..cc285a01 100644 --- a/services/init/lite/init.c +++ b/services/init/lite/init.c @@ -50,6 +50,12 @@ void SystemPrepare(void) { } +void ParseInitCfgByPriority(void) +{ + ReadFileInDir(OTHER_CFG_PATH, ".cfg", ParseInitCfg, NULL); + ReadFileInDir("/vendor/etc/init", ".cfg", ParseInitCfg, NULL); +} + void SystemConfig(void) { InitServiceSpace(); diff --git a/services/init/standard/init.c b/services/init/standard/init.c index 19e0cae3..b5daeebe 100755 --- a/services/init/standard/init.c +++ b/services/init/standard/init.c @@ -370,6 +370,19 @@ INIT_STATIC void TriggerServices(int startMode) } } +void ParseInitCfgByPriority(void) +{ + CfgFiles *files = GetCfgFiles("etc/init"); + for (int i = 0; files && i < MAX_CFG_POLICY_DIRS_CNT; i++) { + if (files->paths[i]) { + if (ReadFileInDir(files->paths[i], ".cfg", ParseInitCfg, NULL) < 0) { + break; + } + } + } + FreeCfgFiles(files); +} + void SystemConfig(void) { INIT_TIMING_STAT timingStat; diff --git a/services/init/standard/init_signal_handler.c b/services/init/standard/init_signal_handler.c index a71f638f..3e8fe9bc 100644 --- a/services/init/standard/init_signal_handler.c +++ b/services/init/standard/init_signal_handler.c @@ -39,12 +39,14 @@ INIT_STATIC void ProcessSignal(const struct signalfd_siginfo *siginfo) Service* service = GetServiceByPid(sigPID); // check child process exit status if (WIFSIGNALED(procStat)) { - INIT_LOGE("Child process %s(pid %d) exit with code : %d", + INIT_LOGE("Child process %s(pid %d) exit with signal : %d", service == NULL ? "Unknown" : service->name, sigPID, WTERMSIG(procStat)); - } - if (WIFEXITED(procStat)) { + } else if (WIFEXITED(procStat)) { INIT_LOGE("Child process %s(pid %d) exit with code : %d", service == NULL ? "Unknown" : service->name, sigPID, WEXITSTATUS(procStat)); + } else { + INIT_LOGE("Child process %s(pid %d) exit with invalid status : %d", + service == NULL ? "Unknown" : service->name, sigPID, procStat); } CmdServiceProcessDelClient(sigPID); INIT_LOGI("SigHandler, SIGCHLD received, Service:%s pid:%d uid:%d status:%d.", -- GitLab