diff --git a/services/updater.cpp b/services/updater.cpp index 76740eda289c4386b90c2aa34d7a3fd356440a3f..22b392ca1836787347ac2b153fd31175c4851fac 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());