no message
parent
486c4ec4e8
commit
c0e60bfd55
|
@ -1,13 +1,56 @@
|
||||||
/*
|
/*
|
||||||
* @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:49:33
|
* @LastEditTime: 2021-07-29 00:14:47
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
|
void _process_start(string path){
|
||||||
|
auto file = popen(path.c_str(),"r");
|
||||||
|
if(file < 0){
|
||||||
|
fprintf(stderr,"execl failed:%s",strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
int prep_map(){
|
||||||
|
FILE *pstr;
|
||||||
|
char cmd[128],buff[512],*p;
|
||||||
|
int iPID;
|
||||||
|
const char *name= "mongod";//要查找的进程名
|
||||||
|
|
||||||
|
int pidPosition=1;
|
||||||
|
int pInfoPosition=7;
|
||||||
|
|
||||||
|
memset(cmd,0,sizeof(cmd));
|
||||||
|
|
||||||
|
sprintf(cmd, "ps ");
|
||||||
|
pstr = popen(cmd, "r");
|
||||||
|
|
||||||
|
if(pstr==NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
memset(buff,0,sizeof(buff));
|
||||||
|
while( 1 ) {
|
||||||
|
fgets(buff,512,pstr);
|
||||||
|
if(feof(pstr))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("buffer=%s",buff);
|
||||||
|
|
||||||
|
}
|
||||||
|
pclose(pstr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
@ -244,6 +287,10 @@ int DaemonizeMonitor::StartMonitor(){
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue