src/linux_parser.cpp
// TODO: Read and return the user ID associated with a process
// REMOVE: [[maybe_unused]] once you define the function
Read and return the user ID associated with a process
REMOVE: [[maybe_unused]] once you define the function
Read and return the user ID associated with a process REMOVE : [[ maybe_unused ]] once you define the function
string LinuxParser::Uid(int pid) 
{
  std::string line;
  std::string col1, col2;
  std::ifstream fileStream(kProcDirectory + to_string(pid) + kStatusFilename);
  if(fileStream.is_open())
  {
    while(getline(fileStream,line))
    {
      std::stringstream linestream(line);
      linestream >> col1;
      if(col1 == "Uid:")
      {
        linestream >> col2;
        break;
      }
    }
  }
  return col2;
}
string LinuxParser :: Uid ( int pid ) { std :: string line ; std :: string col1 , col2 ; std :: ifstream fileStream ( kProcDirectory + to_string ( pid ) + kStatusFilename ) ; if ( fileStream . is_open ( ) ) { while ( getline ( fileStream , line ) ) { std :: stringstream linestream ( line ) ; linestream >> col1 ; if ( col1 == " " ) { linestream >> col2 ; break ; } } } return col2 ; }
TODO: Read and return the user ID associated with a process
REMOVE: [[maybe_unused]] once you define the function
TODO : Read and return the user ID associated with a process REMOVE : [[ maybe_unused ]] once you define the function