33 # define pclose _pclose 42 FILE * fh = popen(cmd.c_str(),
"r");
46 size_t len = fread(buf, 1, 4096, fh);
53 int status = pclose(fh);
56 if (WIFEXITED(status) && WEXITSTATUS(status) == 127) {
61 while (out.size() > 0 &&
C_isspace(out[out.size() - 1])) {
62 out.resize(out.size() - 1);
run an external process and capture its output in a string.
Exception thrown if we encounter a read error.
string stdout_to_string(const string &cmd)
Run command cmd, capture its stdout, and return it as a std::string.
Exception thrown if the program isn't found.
Various handy helpers which std::string really should provide.
include <sys/wait.h>, with portability stuff.