未验证 提交 047f8fc7 编写于 作者: O openharmony_ci 提交者: Gitee

!1610 when critical process exit, panic instead of reboot

Merge pull request !1610 from handy/1208
...@@ -487,6 +487,18 @@ static void CheckOndemandService(Service *service) ...@@ -487,6 +487,18 @@ static void CheckOndemandService(Service *service)
} }
} }
static void DoCriticalServiceAbnormal(void) {
FILE *panic = fopen("/proc/sysrq-trigger", "wb");
if (panic == NULL) {
ExecReboot("reboot");
return;
}
fwrite((void *)"c", 1, 1, panic);
fclose(panic);
}
void ServiceReap(Service *service) void ServiceReap(Service *service)
{ {
INIT_CHECK(service != NULL, return); INIT_CHECK(service != NULL, return);
...@@ -529,7 +541,7 @@ void ServiceReap(Service *service) ...@@ -529,7 +541,7 @@ void ServiceReap(Service *service)
if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) { if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) {
INIT_LOGE("Critical service \" %s \" crashed %d times, rebooting system", INIT_LOGE("Critical service \" %s \" crashed %d times, rebooting system",
service->name, service->crashCount); service->name, service->crashCount);
ExecReboot("reboot"); DoCriticalServiceAbnormal();
} }
} else if (!(service->attribute & SERVICE_ATTR_NEED_RESTART)) { } else if (!(service->attribute & SERVICE_ATTR_NEED_RESTART)) {
if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) { if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册