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

!1615 when critical process exit, panic instead of reboot

Merge pull request !1615 from handy/cherry-pick-1670558263
...@@ -535,7 +535,7 @@ void ServiceReap(Service *service) ...@@ -535,7 +535,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"); ExecReboot("panic");
} }
} 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)) {
......
...@@ -25,7 +25,11 @@ void ExecReboot(const char *value) ...@@ -25,7 +25,11 @@ void ExecReboot(const char *value)
#ifndef STARTUP_INIT_TEST #ifndef STARTUP_INIT_TEST
// install module // install module
InitModuleMgrInstall("rebootmodule"); InitModuleMgrInstall("rebootmodule");
PluginExecCmdByName("reboot", value); if (strstr(value, "reboot") != NULL) {
PluginExecCmdByName("reboot", value);
} else {
PluginExecCmdByName(value, value);
}
#endif #endif
return; return;
} }
......
...@@ -48,6 +48,26 @@ static int DoReboot(int id, const char *name, int argc, const char **argv) ...@@ -48,6 +48,26 @@ static int DoReboot(int id, const char *name, int argc, const char **argv)
return DoRoot_("reboot", RB_AUTOBOOT); return DoRoot_("reboot", RB_AUTOBOOT);
} }
static int DoRebootPanic(int id, const char *name, int argc, const char **argv)
{
UNUSED(id);
UNUSED(name);
UNUSED(argc);
UNUSED(argv);
// clear misc
(void)UpdateMiscMessage(NULL, "reboot", NULL, NULL);
DoJobNow("reboot");
#ifndef STARTUP_INIT_TEST
FILE *panic = fopen("/proc/sysrq-trigger", "wb");
if (panic == NULL) {
return reboot(RB_AUTOBOOT);
}
fwrite((void *)"c", 1, 1, panic);
fclose(panic);
#endif
return 0;
}
static int DoRebootShutdown(int id, const char *name, int argc, const char **argv) static int DoRebootShutdown(int id, const char *name, int argc, const char **argv)
{ {
UNUSED(id); UNUSED(id);
...@@ -130,6 +150,8 @@ static void RebootAdpInit(void) ...@@ -130,6 +150,8 @@ static void RebootAdpInit(void)
AddRebootCmdExecutor("updater", DoRebootUpdater); AddRebootCmdExecutor("updater", DoRebootUpdater);
AddRebootCmdExecutor("charge", DoRebootCharge); AddRebootCmdExecutor("charge", DoRebootCharge);
AddRebootCmdExecutor("suspend", DoRebootSuspend); AddRebootCmdExecutor("suspend", DoRebootSuspend);
AddRebootCmdExecutor("panic", DoRebootPanic);
(void)AddCmdExecutor("panic", DoRebootPanic);
} }
MODULE_CONSTRUCTOR(void) MODULE_CONSTRUCTOR(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册