no message

master
zcy 2021-08-12 00:35:03 +08:00
parent 0da00a604c
commit b6f0846fbf
1 changed files with 27 additions and 22 deletions

View File

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-07-23 23:39:57
* @LastEditTime: 2021-08-11 01:15:55
* @LastEditTime: 2021-08-12 00:34:35
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \generallib\general\src\function\daemon.c
@ -17,7 +17,6 @@ void _process_start(string path){
}
pclose(file);
}
vector<string> StripList(const char *in,const char* d){
vector<string> ret;
vector<uint16_t> pos;
@ -30,11 +29,6 @@ vector<string> StripList(const char *in,const char* d){
int len = strlen(in);
int sublen = strlen(d);
for(int i = 0;i < strlen(in);i++){
std::cout<<i<<"#"<<in[i];
}
std::cout<<std::endl;
if( len <= 0)
return ret;
if(sublen <= 0)
@ -48,7 +42,6 @@ vector<string> StripList(const char *in,const char* d){
}
}
if(found){
// printf("pos start %d\r\n",i);
i += sublen - 1;
pos.push_back(i);
continue;
@ -64,7 +57,6 @@ vector<string> StripList(const char *in,const char* d){
pos_strip_continue.push_back(pos_strip_continue[pos_strip_continue.size() - 1] + 2);
pos_strip_continue.push_back(strlen(in) - 1);
}
std::cout<<pos_strip_continue.size()<<std::endl;
for(int i = 0;i < pos_strip_continue.size()/2;i++){
string ins = string(&in[pos_strip_continue[i*2]],&(in[pos_strip_continue[i*2 + 1]]) + 1);
ret.push_back(ins);
@ -72,36 +64,49 @@ vector<string> StripList(const char *in,const char* d){
return ret;
}
int prep_map(){
FILE *pstr;
typedef struct{
uint16_t pid;
string process_name;
}RuningProcess;
vector<RuningProcess> RangeProcess(){
FILE *pstr;
char cmd[128],buff[512],*p;
vector<RuningProcess> ret;
int iPID;
const char *name= "mongod";//要查找的进程<E8BF9B>?
int pidPosition=1;
int pInfoPosition=7;
int pidPosition = 1;
int pInfoPosition = 7;
memset(cmd,0,sizeof(cmd));
sprintf(cmd, "ps ");
pstr = popen(cmd, "r");
if(pstr==NULL) {
return 1;
return ret;
}
memset(buff,0,sizeof(buff));
bool first = true;
while( 1 ) {
RuningProcess ins;
fgets(buff,512,pstr);
if(first){
first = false;
continue;
}
if(feof(pstr))
{
break;
}
printf("buffer=%s",buff);
auto trip = StripList(buff," ");
ins.pid = atoi(trip[0].c_str());
ins.process_name = trip[3];
ret.push_back(ins);
}
pclose(pstr);
return 1;
return ret;
}
#endif