| 114 | } |
| 115 | |
| 116 | Str *ReadProcess(Str *prog, StrArr *args) { |
| 117 | Str *command = BuildCommand(prog, args); |
| 118 | FILE *pipe = popen(command->c_str(), "r"); |
| 119 | if (!pipe) |
| 120 | return NULL; |
| 121 | Str *result = ReadFile(pipe); |
| 122 | if (pclose(pipe)) |
| 123 | return NULL; |
| 124 | return result; |
| 125 | } |
| 126 | |
| 127 | StrArr *ReadProcessLines(Str *prog, StrArr *args) { |
| 128 | Str *output = ReadProcess(prog, args); |