this can be tested like this:
EDITOR=mg cvs commit
kill cvs
-> mg spins with 100% cpu in ttgetc

While there prevent an unterminated recursion in panic (via ttclose).
I'm not particularly happy with the errorhandling in ttgetc, but this
is the least intrusive change.

comments, oks?

diff --git ttyio.c ttyio.c
index 228a370..5b9021f 100644
--- ttyio.c
+++ ttyio.c
@@ -173,7 +173,9 @@ ttgetc(void)
                                redraw(0, 0);
                                winch_flag = 0;
                        }
-               } else if (ret == 1)
+               } else if (ret == -1 && errno == EIO)
+                       panic("lost stdin");
+               else if (ret == 1)
                        break;
        } while (1);
        return ((int) c) & 0xFF;
@@ -196,6 +198,12 @@ charswaiting(void)
 void
 panic(char *s)
 {
+       static int panicking = 0;
+
+       if (panicking)
+               return;
+       else
+               panicking = 1;
        ttclose();
        (void) fputs("panic: ", stderr);
        (void) fputs(s, stderr);

-- 
I'm not entirely sure you are real.

Reply via email to