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) 
{ 
  string UID,U_name,line,buffer,X;
  std::ifstream stream(kProcDirectory + std::to_string(pid) + kStatusFilename);
  if (stream.is_open())
  {
    while (std::getline(stream, line))
    {
      std::replace(line.begin(), line.end(), ':',' ');
      std::istringstream linestream(line);
      while (linestream>>line>>buffer)
      {
        if (line == "Uid")
        {UID = buffer;
        return UID;}
      }
    }
  }
  return UID;
}
string LinuxParser :: Uid ( int pid ) { string UID , U_name , line , buffer , X ; std :: ifstream stream ( kProcDirectory + std :: to_string ( pid ) + kStatusFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: istringstream linestream ( line ) ; while ( linestream >> line >> buffer ) { if ( line == " " ) { UID = buffer ; return UID ; } } } } return UID ; }
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
// std::cout<< UID << " UID " << line << " line " ;