$OpenBSD: patch-src_tools_c,v 1.3 2004/01/12 05:37:11 jolan Exp $ --- src/tools.c.orig 2003-10-26 16:28:57.000000000 -0600 +++ src/tools.c 2004-01-11 22:32:57.000000000 -0600 @@ -559,6 +559,33 @@ guint i; } +/* read a single char from a file descriptor. If the descriptor + says that it is not available, then try again up to 5 times, + before giving up. + Required for Mac OS 10.3 +*/ + +static gint read_char(gint fd, gchar *c) { +gint rc; +gint retries; + + retries = 5; + + while (retries) { + rc = read(fd, c, 1); + + /* all ok, read one char or EOF */ + if (rc != -1) { + return rc; + } + + /* error code, try again after a little while */ + usleep(100); + retries--; + } + return rc; +} + /* * Read a line from a descriptor. Read the line one byte at a time, * looking for the newline. Works fine in nonblocking mode..here @@ -576,7 +603,7 @@ gchar *str; str = ptr; for (n = 1; n < maxlen; n++) { - if ( (rc = read(fd, &c, 1)) == 1) { + if ( (rc = read_char(fd, &c)) == 1) { *ptr++ = c; if (c == '\n') { break;