src/linux_parser.cpp
// 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() { 
  string line;
  string key;
  int value;
  std::ifstream filestream(kProcDirectory + kStatFilename);
  if (filestream.is_open()) {
    while(std::getline(filestream, line)) {
      std::istringstream linestream(line);
      while(linestream >> key >> value) {
        if (key == "procs_running") {
          return value;
        }
      }
    }
  }
  return value;
}
int LinuxParser :: RunningProcesses ( ) { string line ; string key ; int value ; std :: ifstream filestream ( kProcDirectory + kStatFilename ) ; if ( filestream . is_open ( ) ) { while ( std :: getline ( filestream , line ) ) { std :: istringstream linestream ( line ) ; while ( linestream >> key >> value ) { if ( key == " " ) { return value ; } } } } return value ; }
Read and return the number of running processes
Read and return the number of running processes