src/linux_parser.cpp
// Read and return the total number of processes
Read and return the total number of processes
Read and return the total number of processes
int LinuxParser::TotalProcesses() { 
  string line, key, value;
  std::ifstream stream(kProcDirectory + kStatFilename);
  if (stream.is_open()) {
    while (std::getline(stream, line)) {
      std::istringstream linestream(line);
      while (linestream >> key >> value) {
        if (key == "processes") {
          return stoi(value);
        }
      }
    }
  }
  return stoi(value);
}
int LinuxParser :: TotalProcesses ( ) { string line , key , value ; std :: ifstream stream ( kProcDirectory + kStatFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: istringstream linestream ( line ) ; while ( linestream >> key >> value ) { if ( key == " " ) { return stoi ( value ) ; } } } } return stoi ( value ) ; }
Read and return the total number of processes
Read and return the total number of processes