src/linux_parser.cpp
// TODO: 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) {
  string line, key, memory, kb;
  vector<string> stats{};
  string filePath = kProcDirectory + "/" + to_string(pid) + "/" + kStatFilename;
  std::ifstream istream(filePath);
  if (istream.is_open()) {
    while (std::getline(istream, line)) {
      std::istringstream istringstream(line);
      while (istringstream >> line) {
        stats.emplace_back(line);
      }
    }
    return stol(stats[21]);
  }
  return 0;
}
long LinuxParser :: UpTime ( int pid ) { string line , key , memory , kb ; vector < string > stats { } ; string filePath = kProcDirectory + " " + to_string ( pid ) + " " + kStatFilename ; std :: ifstream istream ( filePath ) ; if ( istream . is_open ( ) ) { while ( std :: getline ( istream , line ) ) { std :: istringstream istringstream ( line ) ; while ( istringstream >> line ) { stats . emplace_back ( line ) ; } } return stol ( stats [ 21 ] ) ; } return 0 ; }
TODO: Read and return the uptime of a process
TODO : Read and return the uptime of a process