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() {
  std::string line;
  int num = 0;
  std::ifstream fileStream(kProcDirectory + kStatFilename);
  if(fileStream.is_open())
  {
    while(std::getline(fileStream, line))
    {
      std::string col1;
      std::istringstream linestream(line);
      linestream >> col1;
      if(col1 == "procs_running")
      {
        linestream >> num;
        break;
      }
    }
  }
  return num;
}
int LinuxParser :: RunningProcesses ( ) { std :: string line ; int num = 0 ; std :: ifstream fileStream ( kProcDirectory + kStatFilename ) ; if ( fileStream . is_open ( ) ) { while ( std :: getline ( fileStream , line ) ) { std :: string col1 ; std :: istringstream linestream ( line ) ; linestream >> col1 ; if ( col1 == " " ) { linestream >> num ; break ; } } } return num ; }
TODO: Read and return the number of running processes
TODO : Read and return the number of running processes