#include <systemd/sd-login.h>
#include <aul.h>
+#include <chrono>
#include <string>
#include "common/utils/glist_range.h"
return true;
}
- ret = aul_terminate_pid_sync_without_restart_for_uid(pid, uid);
- if (ret != AUL_R_OK) {
- LOG(ERROR) << "Failed to kill app[" << appid << "] for uid [" << uid << "]";
- return false;
- }
+ int retry = 3;
+ auto start = std::chrono::steady_clock::now();
+ do {
+ ret = aul_terminate_pid_sync_without_restart_for_uid(pid, uid);
+ if (ret == AUL_R_OK) {
+ return true;
+ } else {
+ LOG(ERROR) << "Failed to terminate app[" << appid
+ << "] for uid [" << uid << "]";
+ auto end = std::chrono::steady_clock::now();
+ auto elapsed_time =
+ std::chrono::duration_cast<std::chrono::milliseconds>(
+ end - start).count();
+ if (elapsed_time >= 5000)
+ break;
+ }
+ } while (retry--);
+
+ /*
+ * The elapsed time exceeded 5 seconds.
+ * According to Tizen policy, the running application should be terminated
+ * within 5 seconds. To terminate the running application forcedly,
+ * we send the kill request to Application Manager.
+ */
+ ret = aul_kill_pid(pid);
+ if (ret == AUL_R_OK)
+ return true;
- return true;
+ LOG(ERROR) << "Failed to kill app[" << appid << "] for uid [" << uid << "]";
+ return false;
}
bool KillApp(const std::string& appid, const uid_t uid) {