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