From 5adcf80a5b908eb78759696078d0c1ba4153df58 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Sun, 19 Jul 2009 19:48:14 +0430 Subject: [PATCH] term: don't read from a closed term --- fbpad.c | 3 +-- term.c | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fbpad.c b/fbpad.c index 916cf64..efc3ab3 100644 --- a/fbpad.c +++ b/fbpad.c @@ -198,8 +198,7 @@ static void check_ufds(struct pollfd *ufds, int n) temp_switch(idx); term_end(); switch_back(idx); - } - if (ufds[i].revents & POLLIN) { + } else if (ufds[i].revents & POLLIN) { temp_switch(idx); term_read(); switch_back(idx); diff --git a/term.c b/term.c index 538228a..8b7ca1e 100644 --- a/term.c +++ b/term.c @@ -153,6 +153,8 @@ static int readpty(void) { if (ptycur < ptylen) return ptybuf[ptycur++]; + if (!term->fd) + return -1; ptylen = read(term->fd, ptybuf, PTYBUFSIZE); if (ptylen == -1 && errno == EAGAIN) { waitpty(); -- 2.11.4.GIT