src/linux_parser.cpp
// Read and return the user ID associated with a process
Read and return the user ID associated with a process
Read and return the user ID associated with a process
string LinuxParser::Uid(int pid) {
  string line, key, uid;
  std::ifstream stream(kProcDirectory + std::to_string(pid) + kStatusFilename);
  if (stream.is_open()) {
    while(std::getline(stream, line)) {
      std::istringstream linestream(line);
      linestream >> key;
      if (key == "Uid:") {
        linestream >> uid;
      }
    }
  }
  return uid;
}
string LinuxParser :: Uid ( int pid ) { string line , key , uid ; std :: ifstream stream ( kProcDirectory + std :: to_string ( pid ) + kStatusFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: istringstream linestream ( line ) ; linestream >> key ; if ( key == " " ) { linestream >> uid ; } } } return uid ; }
Read and return the user ID associated with a process
Read and return the user ID associated with a process