src/linux_parser.cpp
// Todo: Read and return the user associated with a process
// REMOVE: [[maybe_unused]] once you define the function
Read and return the user associated with a process
REMOVE: [[maybe_unused]] once you define the function
Read and return the user associated with a process REMOVE : [[ maybe_unused ]] once you define the function
string LinuxParser::User(int pid) { 
    string uid = Uid(pid);
    string line;
    string username = "";
    std::ifstream file = GetStream(kPasswordPath);
    string name = "x:"+uid;
    while(getline(file,line)) {
        if( line.find(name) != string::npos ) {
            username = line.substr(0, line.find(":"));
            break;
        }
    }
    file.close();
    return username; 
}
string LinuxParser :: User ( int pid ) { string uid = Uid ( pid ) ; string line ; string username = " " ; std :: ifstream file = GetStream ( kPasswordPath ) ; string name = " " + uid ; while ( getline ( file , line ) ) { if ( line . find ( name ) != string :: npos ) { username = line . substr ( 0 , line . find ( " " ) ) ; break ; } } file . close ( ) ; return username ; }
Todo: Read and return the user associated with a process
REMOVE: [[maybe_unused]] once you define the function
Todo : Read and return the user associated with a process REMOVE : [[ maybe_unused ]] once you define the function