no message
parent
8e06ef30a1
commit
c1a585546e
|
@ -18,11 +18,35 @@ void _process_start(string path){
|
|||
pclose(file);
|
||||
}
|
||||
|
||||
vector<string> StripList(const char *in,const char* d){
|
||||
vector<string> 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";//è¦<EFBFBD>查找的进程å<EFBFBD>?
|
||||
|
||||
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; //æ¤æˆ<EFBFBD>员设为TRUEçš„è¯<EFBFBD>则显示新建进程的主窗å<EFBFBD>?
|
||||
BOOL bRet = CreateProcess(
|
||||
NULL, //不在此指定可执行文件的文件名
|
||||
szCommandLine, //命令行参数
|
||||
NULL, //默认进程安全性
|
||||
NULL, //默认进程安全性
|
||||
szCommandLine, //命令行å<EFBFBD>‚æ•?
|
||||
NULL, //默认进程安全�
|
||||
NULL, //默认进程安全�
|
||||
FALSE, //指定当前进程内句柄不可以被子进程继承
|
||||
CREATE_NEW_CONSOLE, //为新进程创建一个新的控制台窗口
|
||||
NULL, //使用本进程的环境变量
|
||||
|
@ -183,7 +207,7 @@ static int test_fork()
|
|||
&pi);
|
||||
if (bRet)
|
||||
{
|
||||
//不使用的句柄最好关掉
|
||||
//ä¸<EFBFBD>使用的å<EFBFBD>¥æŸ„最好关æŽ?
|
||||
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; //æ¤æˆ<EFBFBD>员设为TRUEçš„è¯<EFBFBD>则显示新建进程的主窗å<EFBFBD>?
|
||||
BOOL bRet = CreateProcess(
|
||||
NULL, //不在此指定可执行文件的文件名
|
||||
(LPSTR)path.c_str(), //命令行参数
|
||||
NULL, //默认进程安全性
|
||||
NULL, //默认进程安全性
|
||||
(LPSTR)path.c_str(), //命令行å<EFBFBD>‚æ•?
|
||||
NULL, //默认进程安全�
|
||||
NULL, //默认进程安全�
|
||||
FALSE, //指定当前进程内句柄不可以被子进程继承
|
||||
CREATE_NEW_CONSOLE, //为新进程创建一个新的控制台窗口
|
||||
NULL, //使用本进程的环境变量
|
||||
|
@ -218,7 +242,7 @@ int DaemonizeMonitor::AddNewProcess(string path){
|
|||
&pi);
|
||||
if (bRet)
|
||||
{
|
||||
//不使用的句柄最好关掉
|
||||
//ä¸<EFBFBD>使用的å<EFBFBD>¥æŸ„最好关æŽ?
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
|
||||
|
@ -265,7 +289,7 @@ int DaemonizeMonitor::StartMonitor(){
|
|||
}
|
||||
SetProcessPrivilege("SeDebugPrivilege", 0);
|
||||
if(!found){
|
||||
// 没找到该应用实例就重启应用
|
||||
// 没找到该应用实例就é‡<EFBFBD>å<EFBFBD>¯åº”ç”?
|
||||
auto it = m_path_process.begin();
|
||||
while (it != m_path_process.end())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue