Don't try to receive packet or get keyboard press in case of select() returns error or zero fd's prepared.
Signed-off-by: Vitezslav Samel vitezslav@samel.cz --- src/packet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/packet.c b/src/packet.c index 3e7181a..b48e98f 100644 --- a/src/packet.c +++ b/src/packet.c @@ -154,7 +154,7 @@ void packet_get(int fd, struct pkt_hdr *pkt, int *ch, WINDOW *win) } while ((ss < 0) && (errno == EINTR));
pkt->pkt_len = 0; /* signalize we have no packet prepared */ - if (FD_ISSET(fd, &set)) { + if ((ss > 0) && FD_ISSET(fd, &set)) { struct sockaddr_ll from; socklen_t fromlen = sizeof(struct sockaddr_ll); ssize_t len; @@ -176,7 +176,7 @@ void packet_get(int fd, struct pkt_hdr *pkt, int *ch, WINDOW *win) }
*ch = ERR; /* signalize we have no key ready */ - if (!daemonized && FD_ISSET(0, &set)) + if (!daemonized && (ss > 0) && FD_ISSET(0, &set)) *ch = wgetch(win); }