src/linux_parser.cpp
// TODO: Read and return the user ID associated with a process
/* There are 4 different UIDs in Uid row, they are as follows
Uid: real UID, effective UID, saved set UID, and file system UID
*/
Read and return the user ID associated with a process
There are 4 different UIDs in Uid row, they are as follows
Uid: real UID, effective UID, saved set UID, and file system UID
Read and return the user ID associated with a process There are 4 different UIDs in Uid row they are as follows Uid : real UID effective UID saved set UID and file system UID
string LinuxParser::Uid(int pid) {
  string line, key, uid, uid2, uid3, uid4;
  string filePath =
      kProcDirectory + "/" + to_string(pid) + "/" + kStatusFilename;
  std::ifstream istream(filePath);
  if (istream.is_open()) {
    while (std::getline(istream, line)) {
      std::replace(line.begin(), line.end(), ':', ' ');
      std::istringstream istringstream(line);
      istringstream >> key >> uid >> uid2 >> uid3 >> uid4;
      if (key == "Uid") return uid;
    }
  }
  return string();
}
string LinuxParser :: Uid ( int pid ) { string line , key , uid , uid2 , uid3 , uid4 ; string filePath = kProcDirectory + " " + to_string ( pid ) + " " + kStatusFilename ; std :: ifstream istream ( filePath ) ; if ( istream . is_open ( ) ) { while ( std :: getline ( istream , line ) ) { std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: istringstream istringstream ( line ) ; istringstream >> key >> uid >> uid2 >> uid3 >> uid4 ; if ( key == " " ) return uid ; } } return string ( ) ; }
TODO: Read and return the user ID associated with a process
There are 4 different UIDs in Uid row, they are as follows
Uid: real UID, effective UID, saved set UID, and file system UID
TODO : Read and return the user ID associated with a process There are 4 different UIDs in Uid row they are as follows Uid : real UID effective UID saved set UID and file system UID