Handle standard output closure last

Fixes #1207.
This commit is contained in:
Bastien Dejean 2020-10-12 15:40:57 +02:00
parent 853bb73452
commit e13255e249

View file

@ -86,9 +86,6 @@ int main(int argc, char *argv[])
}; };
while (poll(fds, 2, -1) > 0) { while (poll(fds, 2, -1) > 0) {
if (fds[1].revents & (POLLERR | POLLHUP)) {
break;
}
if (fds[0].revents & POLLIN) { if (fds[0].revents & POLLIN) {
if ((nb = recv(sock_fd, rsp, sizeof(rsp)-1, 0)) > 0) { if ((nb = recv(sock_fd, rsp, sizeof(rsp)-1, 0)) > 0) {
rsp[nb] = '\0'; rsp[nb] = '\0';
@ -104,6 +101,9 @@ int main(int argc, char *argv[])
break; break;
} }
} }
if (fds[1].revents & (POLLERR | POLLHUP)) {
break;
}
} }
close(sock_fd); close(sock_fd);