Просмотр исходного кода

#IQRV #comment [Guardian] 恢复清理策略,判断有无新的spshell,有则不处理异常

gifur 4 лет назад
Родитель
Сommit
3d3b50b6ab
1 измененных файлов с 22 добавлено и 6 удалено
  1. 22 6
      Tool/guardian/guardian.cpp

+ 22 - 6
Tool/guardian/guardian.cpp

@@ -1622,18 +1622,34 @@ static void sig_handle(int signo)
 			if (WIFEXITED(status)) {
 				sprintf(szMsg, "child process %d terminated normal with exit code: %d", pid, WEXITSTATUS(status));
 			} else {
-				sprintf(szMsg, "child process %d has been terminated unexpectly by signal %d", pid, WTERMSIG(status));
+				const int signum = WTERMSIG(status);
+				sprintf(szMsg, "child process %d has been terminated unexpectly by signal %d", pid, signum);
+				//if(signum != SIGKILL) 
 				excep = true;
 			}
 			LogSingleMsg(szMsg);
             if (g_SpShellPID != 0 && g_SpShellPID == pid) {
 				LogSingleMsg("Specified spshell process has exited!");
 				g_SpShellPID = 0;
-				//if (excep) {
-				//	LogSingleMsg("Confirm other relate process has been terminated.");
-				//	char* processes[] = { sphost_execute_name, cefclient_execute_name };
-				//	osutil_terminate_related_process(processes, array_size(processes));
-				//}
+				if (excep) {
+					LogSingleMsg("Confirm other relate process has been terminated.");
+                    int count = 60;
+                    alive_process_info processes[60];
+                    memset(processes, 0, sizeof(processes));
+                    if (!osutil_detect_unique_app(relate_processes_ex, array_size(relate_processes_ex), &count, processes)) {
+						bool spshell_exist(false);
+                        for (int i = 0; i < count; ++i) {
+							if (strcmp(processes[i].name, spshell_execute_name) == 0) {
+								spshell_exist = true;
+								break;
+							}
+                        }
+                        for (int i = 0; !spshell_exist && i < count; ++i) {
+                            kill(processes[i].pid, SIGKILL);
+                            LogToFile(true, true, true, "kill", processes[i].name, processes[i].pid, errno);
+                        }
+                    }
+				}
             }
         }
 		break;