From f1c4938b76627ef2617505ac9d7260d6066e926a Mon Sep 17 00:00:00 2001 From: ldy Date: Wed, 14 May 2025 13:34:39 +0000 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AEdeath=20sig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ldy --- services/updater.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/updater.cpp b/services/updater.cpp index 76740eda..22b392ca 100644 --- a/services/updater.cpp +++ b/services/updater.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,17 @@ int g_percentage = 100; int g_tmpProgressValue; int g_tmpValue; +static void SetBinaryDeathSig(void) +{ + if (Utils::IsUpdaterMode()) { + LOG(INFO) << "no need set death sig, when updater mode"; + return; + } + if (prctl(PR_SET_PDEATHSIG, SIGTERM) == -1) { + LOG(ERROR) << "prctl failed " << strerror(errno); + } +} + int32_t ExtractUpdaterBinary(PkgManager::PkgManagerPtr manager, std::string &packagePath, const std::string &updaterBinary) { @@ -509,6 +521,7 @@ void HandleChildOutput(const std::string &buffer, int32_t bufferLen, bool &retry void ExcuteSubProc(const UpdaterParams &upParams, const std::string &fullPath, int pipeWrite) { UPDATER_INIT_RECORD; + SetBinaryDeathSig(); // Set process scheduler to normal if current scheduler is // SCHED_FIFO, which may cause bad performance. int policy = syscall(SYS_sched_getscheduler, getpid()); -- Gitee