$NetBSD: patch-ac,v 1.3 2000/08/02 17:33:45 thorpej Exp $ Make this compile on Solaris. Fix a bug where rtty would loop forever if its parent process (such as a shell) were to die and close rtty's standard input. --- rtty.c.orig Fri Aug 23 15:25:28 1996 +++ rtty.c Wed Aug 2 10:25:30 2000 @@ -35,6 +35,10 @@ #include #include +#if (defined(__sun__) && defined(__svr4__)) +#include +#endif + #include "rtty.h" #ifdef NEED_BITYPES_H # include "bitypes.h" @@ -266,13 +270,16 @@ static void tty_input(fd) { static enum {base, need_cr, tilde} state = base; + ssize_t cnt; + int readone = 0; u_char buf[1]; #if 0 fcntl(Tty, F_SETFL, fcntl(Tty, F_GETFL, 0)|O_NONBLOCK); #endif - while (1 == read(fd, buf, 1)) { + while (1 == (cnt = read(fd, buf, 1))) { u_char ch = buf[0]; + readone = 1; switch (state) { case base: @@ -346,6 +353,14 @@ write(Log, buf, 1); } } + + if (readone == 0 && cnt == 0) { + /* + * True EOF -- get out now rather than loop forever. + */ + quit(0); + } + #if 0 fcntl(Tty, F_SETFL, fcntl(Tty, F_GETFL, 0)&~O_NONBLOCK); #endif