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) { 
  std::ifstream StatusFile(kProcDirectory+to_string(pid)+kStatusFilename);
  string line,key="",value="";
  if(StatusFile.is_open())
  {
    while(getline(StatusFile,line))
    {
      std::istringstream MyStream(line);
      MyStream >> key ;
      if(key == "Uid:")
      {
        MyStream >> value;
        return value;
      }
    }
  }
return "-1";
 }
string LinuxParser :: Uid ( int pid ) { std :: ifstream StatusFile ( kProcDirectory + to_string ( pid ) + kStatusFilename ) ; string line , key = " " , value = " " ; if ( StatusFile . is_open ( ) ) { while ( getline ( StatusFile , line ) ) { std :: istringstream MyStream ( line ) ; MyStream >> key ; if ( key == " " ) { MyStream >> value ; return value ; } } } return " " ; }
Read and return the user ID associated with a process
Read and return the user ID associated with a process
/*return string();*/