src/linux_parser.cpp
string LinuxParser::Command(int pid) {
string cmd_val, line;
  std::ifstream stream(kProcDirectory + std::to_string(pid) + kCmdlineFilename);
  if (stream.is_open()) {
    while (std::getline(stream, line)){
      std::istringstream linestream(line);
      std::replace(line.begin(), line.end(), ' ', '*');
      while (linestream >> cmd_val) {
          std::replace(cmd_val.begin(), cmd_val.end(), '*', ' ');
          return cmd_val;
        }
    }
  }
    return string();
}
// TODO: Read and return the command associated with a process
// REMOVE: [[maybe_unused]] once you define the function
Read and return the command associated with a process
REMOVE: [[maybe_unused]] once you define the function
Read and return the command associated with a process REMOVE : [[ maybe_unused ]] once you define the function
string LinuxParser::Command(int pid) {
string cmd_val, line;
  std::ifstream stream(kProcDirectory + std::to_string(pid) + kCmdlineFilename);
  if (stream.is_open()) {
    while (std::getline(stream, line)){
      std::istringstream linestream(line);
      std::replace(line.begin(), line.end(), ' ', '*');
      while (linestream >> cmd_val) {
          std::replace(cmd_val.begin(), cmd_val.end(), '*', ' ');
          return cmd_val;
        }
    }
  }
    return string();
}
string LinuxParser :: Command ( int pid ) { string cmd_val , line ; std :: ifstream stream ( kProcDirectory + std :: to_string ( pid ) + kCmdlineFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: istringstream linestream ( line ) ; std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; while ( linestream >> cmd_val ) { std :: replace ( cmd_val . begin ( ) , cmd_val . end ( ) , ' ' , ' ' ) ; return cmd_val ; } } } return string ( ) ; }
TODO: Read and return the command associated with a process
REMOVE: [[maybe_unused]] once you define the function
TODO : Read and return the command associated with a process REMOVE : [[ maybe_unused ]] once you define the function