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 unsigned LinuxParser::UpTime(int pid) { 
    string filepath = kProcDirectory + "/" + std::to_string(pid) + kStatFilename;
    std::ifstream file = GetStream(filepath);
    long unsigned process_uptime_jiffy;
    string line;
    std::getline(file, line);
    std::istringstream buf(line);
    std::istream_iterator<string> beg(buf), end;
    std::vector<string> values(beg, end);
    process_uptime_jiffy = stol(values[13]);
    file.close();
    return process_uptime_jiffy;
}
long unsigned LinuxParser :: UpTime ( int pid ) { string filepath = kProcDirectory + " " + std :: to_string ( pid ) + kStatFilename ; std :: ifstream file = GetStream ( filepath ) ; long unsigned process_uptime_jiffy ; string line ; std :: getline ( file , line ) ; std :: istringstream buf ( line ) ; std :: istream_iterator < string > beg ( buf ) , end ; std :: vector < string > values ( beg , end ) ; process_uptime_jiffy = stol ( values [ 13 ] ) ; file . close ( ) ; return process_uptime_jiffy ; }
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