From c1a585546e107230ce96daf262d6c8f8b281699e Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Thu, 5 Aug 2021 01:52:29 +0800 Subject: [PATCH] no message --- general/src/function/daemon.cpp | 48 ++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/general/src/function/daemon.cpp b/general/src/function/daemon.cpp index cf273b9..e9da851 100644 --- a/general/src/function/daemon.cpp +++ b/general/src/function/daemon.cpp @@ -18,11 +18,35 @@ void _process_start(string path){ pclose(file); } +vector StripList(const char *in,const char* d){ + vector ret; + if((nullptr == in)|| (nullptr == d)){ + return ret; + } + int len = strlen(in); + for(int i = 0;i < (len - strlen(d)) ; i++){ + bool found = true; + for(int j = 0;j < strlen(d);j++){ + if(in[i + j] == d[j]){ + found = false; + } + } + if(found){ + string x(); + i+= strlen(d); + continue; + } + printf("%d\r\n",i); + + } + return ret; +} + int prep_map(){ FILE *pstr; char cmd[128],buff[512],*p; int iPID; - const char *name= "mongod";//要查找的进程名 + const char *name= "mongod";//要查找的进程? int pidPosition=1; int pInfoPosition=7; @@ -169,12 +193,12 @@ static int test_fork() STARTUPINFO si = {sizeof(si)}; PROCESS_INFORMATION pi; si.dwFlags = STARTF_USESHOWWINDOW; //指定wShowWindow成员有效 - si.wShowWindow = TRUE; //此成员设为TRUE的话则显示新建进程的主窗口 + si.wShowWindow = TRUE; //此成员设为TRUE的话则显示新建进程的主窗? BOOL bRet = CreateProcess( NULL, //不在此指定可执行文件的文件名 - szCommandLine, //命令行参数 - NULL, //默认进程安全性 - NULL, //默认进程安全性 + szCommandLine, //命令行参? + NULL, //默认进程安全? + NULL, //默认进程安全? FALSE, //指定当前进程内句柄不可以被子进程继承 CREATE_NEW_CONSOLE, //为新进程创建一个新的控制台窗口 NULL, //使用本进程的环境变量 @@ -183,7 +207,7 @@ static int test_fork() &pi); if (bRet) { - //不使用的句柄最好关掉 + //不使用的句柄最好关? CloseHandle(pi.hThread); CloseHandle(pi.hProcess); printf("new process id %d\n", pi.dwProcessId); @@ -204,12 +228,12 @@ int DaemonizeMonitor::AddNewProcess(string path){ STARTUPINFO si = {sizeof(si)}; PROCESS_INFORMATION pi; si.dwFlags = STARTF_USESHOWWINDOW; //指定wShowWindow成员有效 - si.wShowWindow = TRUE; //此成员设为TRUE的话则显示新建进程的主窗口 + si.wShowWindow = TRUE; //此成员设为TRUE的话则显示新建进程的主窗? BOOL bRet = CreateProcess( NULL, //不在此指定可执行文件的文件名 - (LPSTR)path.c_str(), //命令行参数 - NULL, //默认进程安全性 - NULL, //默认进程安全性 + (LPSTR)path.c_str(), //命令行参? + NULL, //默认进程安全? + NULL, //默认进程安全? FALSE, //指定当前进程内句柄不可以被子进程继承 CREATE_NEW_CONSOLE, //为新进程创建一个新的控制台窗口 NULL, //使用本进程的环境变量 @@ -218,7 +242,7 @@ int DaemonizeMonitor::AddNewProcess(string path){ &pi); if (bRet) { - //不使用的句柄最好关掉 + //不使用的句柄最好关? CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -265,7 +289,7 @@ int DaemonizeMonitor::StartMonitor(){ } SetProcessPrivilege("SeDebugPrivilege", 0); if(!found){ - // 没找到该应用实例就重启应用 + // 没找到该应用实例就重启应? auto it = m_path_process.begin(); while (it != m_path_process.end()) {