From c0e60bfd55ce23fc30a4db0ea4243f4425336fe2 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Thu, 29 Jul 2021 00:17:41 +0800 Subject: [PATCH] no message --- general/src/function/daemon.cpp | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/general/src/function/daemon.cpp b/general/src/function/daemon.cpp index bde8137..37e0aef 100644 --- a/general/src/function/daemon.cpp +++ b/general/src/function/daemon.cpp @@ -1,13 +1,56 @@ /* * @Author: your name * @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 * @Description: In User Settings Edit * @FilePath: \generallib\general\src\function\daemon.c */ #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 @@ -244,6 +287,10 @@ int DaemonizeMonitor::StartMonitor(){ } return 0; #endif + +#ifdef linux + +#endif } @@ -254,7 +301,7 @@ int DaemonizeMonitor::StopMonitor(string){ } /* - + */ int DaemonizeMonitor::StopProcess(string path){ #ifdef _WIN32