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 * @Author: your name
* @Date: 2021-07-23 23:39:57 * @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 * @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
@ -17,7 +17,6 @@ void _process_start(string path){
} }
pclose(file); pclose(file);
} }
vector<string> StripList(const char *in,const char* d){ vector<string> StripList(const char *in,const char* d){
vector<string> ret; vector<string> ret;
vector<uint16_t> pos; vector<uint16_t> pos;
@ -30,11 +29,6 @@ vector<string> StripList(const char *in,const char* d){
int len = strlen(in); int len = strlen(in);
int sublen = strlen(d); int sublen = strlen(d);
for(int i = 0;i < strlen(in);i++){
std::cout<<i<<"#"<<in[i];
}
std::cout<<std::endl;
if( len <= 0) if( len <= 0)
return ret; return ret;
if(sublen <= 0) if(sublen <= 0)
@ -48,7 +42,6 @@ vector<string> StripList(const char *in,const char* d){
} }
} }
if(found){ if(found){
// printf("pos start %d\r\n",i);
i += sublen - 1; i += sublen - 1;
pos.push_back(i); pos.push_back(i);
continue; 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(pos_strip_continue[pos_strip_continue.size() - 1] + 2);
pos_strip_continue.push_back(strlen(in) - 1); 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++){ 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); string ins = string(&in[pos_strip_continue[i*2]],&(in[pos_strip_continue[i*2 + 1]]) + 1);
ret.push_back(ins); ret.push_back(ins);
@ -72,36 +64,49 @@ vector<string> StripList(const char *in,const char* d){
return ret; return ret;
} }
int prep_map(){ typedef struct{
FILE *pstr; uint16_t pid;
char cmd[128],buff[512],*p; string process_name;
int iPID; }RuningProcess;
const char *name= "mongod";//要查找的进程<E8BF9B>?
int pidPosition=1;
int pInfoPosition=7; vector<RuningProcess> RangeProcess(){
FILE *pstr;
char cmd[128],buff[512],*p;
vector<RuningProcess> ret;
int iPID;
int pidPosition = 1;
int pInfoPosition = 7;
memset(cmd,0,sizeof(cmd)); memset(cmd,0,sizeof(cmd));
sprintf(cmd, "ps "); sprintf(cmd, "ps ");
pstr = popen(cmd, "r"); pstr = popen(cmd, "r");
if(pstr==NULL) { if(pstr==NULL) {
return 1; return ret;
} }
memset(buff,0,sizeof(buff)); memset(buff,0,sizeof(buff));
bool first = true;
while( 1 ) { while( 1 ) {
RuningProcess ins;
fgets(buff,512,pstr); fgets(buff,512,pstr);
if(first){
first = false;
continue;
}
if(feof(pstr)) if(feof(pstr))
{ {
break; 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); pclose(pstr);
return 1; return ret;
} }
#endif #endif