C++的字符串拼接和判断

[复制链接]
 楼主| keer_zu 发表于 2023-2-10 17:43 | 显示全部楼层 |阅读模式


  1. case EMStateBase::INVALID:{
  2.             if(msg.second == EMStateBase::IDLE){
  3.                 std::string lunch;
  4.                 if(msg.first == FG_SM){
  5.                     //lunch = "SM&";
  6.                     lunch = "on -T SM_t -u SM_u SM&";
  7.                 }else{
  8.                     //get corresponding process
  9.                     if(processes.front() == "LogService") {
  10.                                 (void)system("setfacl -m user:LogService_u:rw /var/qlog/");
  11.                     }
  12.                        
  13.                     lunch = std::string("on -T ")  + processes.front() + std::string("_t -u ") + processes.front() + std::string("_u ") + processes.front() + std::string("&");
  14.                         printf("=======cmd:%s\n",lunch.c_str());
  15.                 }
 楼主| keer_zu 发表于 2023-2-14 15:33 | 显示全部楼层
  1.     if(0 != ProcPreference::getPreference().get(msg.first, curState)){
  2.         LOGE("%sProcPreference not found =%d",__func__,msg.first);
  3.         return;
  4.     }
  5.     auto config = ConfigurationImpl::getInstance();
  6.     std::vector<std::string> processes;
  7.     if((msg.first != FG_SM) && (config->getProcess(static_cast<FG_TYPE>(msg.first), processes) != 0)){
  8.         LOGE("can not find process info,fg=%d,process size=%d",msg.first,processes.size());
  9.         return;
  10.     }
  11.     switch(curState.state){
  12.         case EMStateBase::INVALID:{
  13.             if(msg.second == EMStateBase::IDLE){
  14.                 std::string lunch;
  15.                 if(msg.first == FG_SM){
  16.                     //lunch = "SM&";printf("=== %d:\n",__LINE__);
  17.                     lunch = "on -T SM_t -u SM_u SM&";std::cout << " +sm lunch: " << lunch << std::endl;
  18.                 }else{
  19.                     //get corresponding process
  20.                     if(processes.front() == std::string("LogService")) {
  21.                                 (void)system("setfacl -m user:LogService_u:rw /var/qlog/");
  22.                     }
  23.                     lunch = std::string("on -T ")  + processes.front() + std::string("_t -u ") + processes.front() + std::string("_u ") + processes.front() + std::string("&");
  24.                         std::cout << " + lunch: " << lunch << std::endl;
  25.                 }
  26.                 //fork process
  27.                 LOGE("lunch process=%s ",lunch.c_str());
  28.                 (void)system(lunch.c_str());printf("=== %d:\n",__LINE__);
  29.                 //if((-1 != result) && (WIFEXITED(result)) && (!(WEXITSTATUS(result))))
  30.                 MonitorItem item;
  31.                 item.setTimeMS(1000);
  32.                 item.setMonitorItem(msg.first, EMStateBase::INVALID, EMStateBase::IDLE);
  33.             }else{
  34.                 LOGE("%s current state=%d,expected state=%d",__func__,curState.state,msg.second);
  35.             }
  36.         }break;


您需要登录后才可以回帖 登录 | 注册

本版积分规则

1478

主题

12917

帖子

55

粉丝
快速回复 在线客服 返回列表 返回顶部

1478

主题

12917

帖子

55

粉丝
快速回复 在线客服 返回列表 返回顶部