no message
parent
a58d20d811
commit
486c4ec4e8
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* @Author: your name
|
* @Author: your name
|
||||||
* @Date: 2021-07-23 23:39:57
|
* @Date: 2021-07-23 23:39:57
|
||||||
* @LastEditTime: 2021-07-26 23:44:58
|
* @LastEditTime: 2021-07-26 23:49:33
|
||||||
* @LastEditors: Please set LastEditors
|
* @LastEditors: Please set LastEditors
|
||||||
* @Description: In User Settings Edit
|
* @Description: In User Settings Edit
|
||||||
* @FilePath: \generallib\general\src\function\daemon.c
|
* @FilePath: \generallib\general\src\function\daemon.c
|
||||||
|
@ -9,6 +9,8 @@
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
static BOOL KillProcess(DWORD dwPid)
|
static BOOL KillProcess(DWORD dwPid)
|
||||||
{
|
{
|
||||||
HANDLE hPrc;
|
HANDLE hPrc;
|
||||||
|
@ -146,6 +148,7 @@ static int test_fork()
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DaemonizeMonitor::DaemonizeMonitor(string path){
|
DaemonizeMonitor::DaemonizeMonitor(string path){
|
||||||
this->m_path_process.push_back(path);
|
this->m_path_process.push_back(path);
|
||||||
|
@ -154,6 +157,7 @@ DaemonizeMonitor::DaemonizeMonitor(string path){
|
||||||
|
|
||||||
int DaemonizeMonitor::AddNewProcess(string path){
|
int DaemonizeMonitor::AddNewProcess(string path){
|
||||||
this->m_path_process.push_back(path);
|
this->m_path_process.push_back(path);
|
||||||
|
#ifdef _WIN32
|
||||||
STARTUPINFO si = {sizeof(si)};
|
STARTUPINFO si = {sizeof(si)};
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
si.dwFlags = STARTF_USESHOWWINDOW; //指定wShowWindow成员有效
|
si.dwFlags = STARTF_USESHOWWINDOW; //指定wShowWindow成员有效
|
||||||
|
@ -180,9 +184,12 @@ int DaemonizeMonitor::AddNewProcess(string path){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int DaemonizeMonitor::StartMonitor(){
|
int DaemonizeMonitor::StartMonitor(){
|
||||||
|
#ifdef _WIN32
|
||||||
DWORD Proc_pid[1024], Retn_bytes, Proc_count, Retn_bytes2;
|
DWORD Proc_pid[1024], Retn_bytes, Proc_count, Retn_bytes2;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HMODULE hMod[1024];
|
HMODULE hMod[1024];
|
||||||
|
@ -236,18 +243,21 @@ int DaemonizeMonitor::StartMonitor(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DaemonizeMonitor::StopMonitor(string){
|
int DaemonizeMonitor::StopMonitor(string){
|
||||||
|
#ifdef _WIN32
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
*/
|
*/
|
||||||
int DaemonizeMonitor::StopProcess(string path){
|
int DaemonizeMonitor::StopProcess(string path){
|
||||||
|
#ifdef _WIN32
|
||||||
if(m_running_pid.find(path) != m_running_pid.end()){
|
if(m_running_pid.find(path) != m_running_pid.end()){
|
||||||
DWORD pid = m_running_pid.at(path);
|
DWORD pid = m_running_pid.at(path);
|
||||||
m_running_pid.erase(path);
|
m_running_pid.erase(path);
|
||||||
|
@ -258,4 +268,5 @@ int DaemonizeMonitor::StopProcess(string path){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
Loading…
Reference in New Issue