src/linux_parser.cpp
// TODO: Read and return the user associated with a process
Read and return the user associated with a process
Read and return the user associated with a process
string LinuxParser::User(int pid) {
  string uid = LinuxParser::Uid(pid);
  string line;
  string user;
  std::ifstream stream(kPasswordPath);
  if (stream.is_open()) {
    while (std::getline(stream, line)) {
      if (line.find(uid) != std::string::npos) {
        user = line.substr(0, line.find(":"));
        break;
      }
    }
  }
  return user;
}
string LinuxParser :: User ( int pid ) { string uid = LinuxParser :: Uid ( pid ) ; string line ; string user ; std :: ifstream stream ( kPasswordPath ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { if ( line . find ( uid ) != std :: string :: npos ) { user = line . substr ( 0 , line . find ( " " ) ) ; break ; } } } return user ; }
TODO: Read and return the user associated with a process
TODO : Read and return the user associated with a process