support read error in shell_eval

This commit is contained in:
Maxime Coste 2012-03-08 21:15:37 +00:00
parent 97648b1fda
commit f2fd2b125a

View File

@ -116,7 +116,11 @@ static void shell_eval(std::vector<std::string>& params,
std::string output; std::string output;
char buffer[1024]; char buffer[1024];
while (size_t size = read(read_pipe[0], buffer, 1024)) while (size_t size = read(read_pipe[0], buffer, 1024))
{
if (size == -1)
break;
output += std::string(buffer, buffer+size); output += std::string(buffer, buffer+size);
}
close(read_pipe[0]); close(read_pipe[0]);
waitpid(pid, NULL, 0); waitpid(pid, NULL, 0);