stop reading at end-of-file.

This commit is contained in:
Kelvin Sherlock 2016-01-27 13:18:27 -05:00
parent dc76f5addf
commit 32bca0bad6

View File

@ -2,6 +2,7 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <cerrno>
#include <algorithm> #include <algorithm>
%%{ %%{
@ -347,8 +348,10 @@ command_ptr read_fd(int fd) {
for(;;) { for(;;) {
ssize_t s = read(fd, buffer, sizeof(buffer)); ssize_t s = read(fd, buffer, sizeof(buffer));
if (s < 0) { if (s < 0) {
if (errno == EINTR) continue;
throw std::runtime_error("MPW Shell - Read error."); throw std::runtime_error("MPW Shell - Read error.");
} }
if (s == 0) break;
p.process(buffer, s); p.process(buffer, s);
} }
return p.finish(); return p.finish();