src/linux_parser.cpp
// DONE: Read and return the uptime of a process
Read and return the uptime of a process
Read and return the uptime of a process
long LinuxParser::UpTime(int pid) {
  long upTimePid;
  string line, time, value;
  int i = 0;
  std::ifstream filestream(kProcDirectory + to_string(pid) + kStatFilename);
  if (filestream.is_open()) {
    std::getline(filestream, line);
    std::istringstream linestream(line);
    while (linestream >> value) {
      i++;
      if (i == 22) upTimePid = UpTime() - stol(value)/sysconf(_SC_CLK_TCK);
    }
  }
  return upTimePid;
}
long LinuxParser :: UpTime ( int pid ) { long upTimePid ; string line , time , value ; int i = 0 ; std :: ifstream filestream ( kProcDirectory + to_string ( pid ) + kStatFilename ) ; if ( filestream . is_open ( ) ) { std :: getline ( filestream , line ) ; std :: istringstream linestream ( line ) ; while ( linestream >> value ) { i ++ ; if ( i == 22 ) upTimePid = UpTime ( ) - stol ( value ) / sysconf ( _SC_CLK_TCK ) ; } } return upTimePid ; }
DONE: Read and return the uptime of a process
DONE : Read and return the uptime of a process