mirror of
https://github.com/openharmony/appexecfwk_standard.git
synced 2026-07-20 14:33:41 -04:00
Fix the ams crash caused by list erase.
Signed-off-by: jsj <jinsenjun@huawei.com>
This commit is contained in:
@@ -647,13 +647,13 @@ private:
|
||||
bool process_exist(pid_t &pid);
|
||||
|
||||
/**
|
||||
* CheckALLProcessExist, Determine whether all processes exist .
|
||||
* CheckAllProcessExist, Determine whether all processes exist .
|
||||
*
|
||||
* @param pids, process number collection to exit.
|
||||
*
|
||||
* @return true, Returns that a process exists and all other processes do not exist.
|
||||
*/
|
||||
bool CheckALLProcessExist(std::list<pid_t> &pids);
|
||||
bool CheckAllProcessExist(std::list<pid_t> &pids);
|
||||
|
||||
/**
|
||||
* SystemTimeMillis, Get system time.
|
||||
|
||||
@@ -440,7 +440,7 @@ bool AppMgrServiceInner::WaitForRemoteProcessExit(std::list<pid_t> &pids, const
|
||||
{
|
||||
int64_t delayTime = SystemTimeMillis() - startTime;
|
||||
while (delayTime < KILL_PROCESS_TIMEOUT_MICRO_SECONDS) {
|
||||
if (CheckALLProcessExist(pids)) {
|
||||
if (CheckAllProcessExist(pids)) {
|
||||
return true;
|
||||
}
|
||||
usleep(KILL_PROCESS_DELAYTIME_MICRO_SECONDS);
|
||||
@@ -479,18 +479,18 @@ bool AppMgrServiceInner::process_exist(pid_t &pid)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AppMgrServiceInner::CheckALLProcessExist(std::list<pid_t> &pids)
|
||||
bool AppMgrServiceInner::CheckAllProcessExist(std::list<pid_t> &pids)
|
||||
{
|
||||
for (auto iter = pids.begin(); iter != pids.end(); ) {
|
||||
if (!process_exist(*iter) && pids.size() != 0) {
|
||||
pids.erase(iter);
|
||||
if (pids.empty()) {
|
||||
return true;
|
||||
}
|
||||
if (!process_exist(*iter)) {
|
||||
iter = pids.erase(iter);
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
if (pids.empty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user