src/linux_parser.cpp
// TODO: Read and return the number of running processes
Read and return the number of running processes
Read and return the number of running processes
int LinuxParser::RunningProcesses() { 
  int Running_process;
  string line, R_P;
  std::ifstream stream(kProcDirectory + kStatFilename);
  if (stream.is_open()){
    while (std::getline(stream, line)){
      std::istringstream linestream(line);
      while (linestream>>line>>R_P){
        if (line == "procs_running"){Running_process = std::stoi(R_P);}
      }
    }
  }
  return Running_process;}
int LinuxParser :: RunningProcesses ( ) { int Running_process ; string line , R_P ; std :: ifstream stream ( kProcDirectory + kStatFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: istringstream linestream ( line ) ; while ( linestream >> line >> R_P ) { if ( line == " " ) { Running_process = std :: stoi ( R_P ) ; } } } } return Running_process ; }
TODO: Read and return the number of running processes
TODO : Read and return the number of running processes
// std::replace(line.begin(), line.end(), ':',' '); // std::cout << T_P <<"  " << Total_process<< "\n";