sim_console: Fix polling to check for POLLIN
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 19 Jun 2020 10:27:31 +0000 (20:27 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 25 Jun 2020 22:17:23 +0000 (08:17 +1000)
Under some circumstances we get POLLHUP which we incorrectly
treat as having a character in the buffer.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
sim_console_c.c

index b3920c1e276219ec078431c4f90aecff4a1e1fe6..a2c9d55f6a0dc45ece3bf1e04c56268cfc1891fd 100644 (file)
@@ -71,8 +71,11 @@ void sim_console_poll(unsigned char *__rt)
        ret = poll(fdset, 1, 0);
        //fprintf(stderr, "poll returns %d\n", ret);
 
-       if (ret == 1)
-               val = 1;
+       if (ret == 1) {
+               if (fdset[0].revents & POLLIN)
+                       val = 1;
+//             fprintf(stderr, "poll revents: 0x%x\n", fdset[0].revents);
+       }
 
        to_std_logic_vector(val, __rt, 64);
 }