src/linux_parser.cpp
// TODO: Read and return the uptime of a process
// REMOVE: [[maybe_unused]] once you define the function
Read and return the uptime of a process
REMOVE: [[maybe_unused]] once you define the function
Read and return the uptime of a process REMOVE : [[ maybe_unused ]] once you define the function
long LinuxParser::UpTime(int pid) 
{
  std::string line;
  std::string col;
  long starttime;
  std::ifstream fileStream(kProcDirectory + to_string(pid) + kStatFilename);
  if(fileStream.is_open())
  {
    getline(fileStream,line);
    std::stringstream linestream(line);
    for(int i=0; i<21; i++)
    {
      linestream>> col;
    }
    linestream >> starttime;
  }
  return starttime/sysconf(_SC_CLK_TCK);
}
long LinuxParser :: UpTime ( int pid ) { std :: string line ; std :: string col ; long starttime ; std :: ifstream fileStream ( kProcDirectory + to_string ( pid ) + kStatFilename ) ; if ( fileStream . is_open ( ) ) { getline ( fileStream , line ) ; std :: stringstream linestream ( line ) ; for ( int i = 0 ; i < 21 ; i ++ ) { linestream >> col ; } linestream >> starttime ; } return starttime / sysconf ( _SC_CLK_TCK ) ; }
TODO: Read and return the uptime of a process
REMOVE: [[maybe_unused]] once you define the function
TODO : Read and return the uptime of a process REMOVE : [[ maybe_unused ]] once you define the function