FACT++  1.0
bool Readline::ExecuteShellCommand ( const std::string &  cmd)
virtual

Execute a shell command through a pipe. Write stdout to rl_outstream

Parameters
cmdCommand to be executed
Returns
always true

Definition at line 920 of file Readline.cc.

Referenced by GetUpdatePrompt(), and Process().

921 {
922  FILE *pipe = popen(cmd.c_str(), "r");
923  if (!pipe)
924  {
925  fprintf(rl_outstream, "ERROR - Could not create pipe '%s': %m\n", cmd.c_str());
926  return true;
927  }
928 
929  while (1)
930  {
931  char buf[1024];
932 
933  const size_t sz = fread(buf, 1, 1024, pipe);
934 
935  fwrite(buf, 1, sz, rl_outstream);
936 
937  if (feof(pipe) || ferror(pipe))
938  break;
939  }
940 
941  if (ferror(pipe))
942  fprintf(rl_outstream, "ERROR - Reading from pipe '%s': %m\n", cmd.c_str());
943 
944  pclose(pipe);
945 
946  fprintf(rl_outstream, "\n");
947 
948  return true;
949 }

+ Here is the caller graph for this function: