2 % (c) The GRASP/AQUA Project, Glasgow University, 1994
4 \subsection[inputReady.lc]{hReady Runtime Support}
11 #ifdef HAVE_SYS_TYPES_H
12 #include <sys/types.h>
30 if (feof((FILE *) fp))
33 /* Get the original file status flags */
34 while ((flags = fcntl(fileno((FILE *) fp), F_GETFL)) < 0) {
43 /* If it's not already non-blocking, make it so */
44 if (!(flags & O_NONBLOCK)) {
45 while (fcntl(fileno((FILE *) fp), F_SETFL, flags | O_NONBLOCK) < 0) {
46 /* still highly unlikely */
54 /* Now try to get a character */
55 while ((c = getc((FILE *) fp)) == EOF && errno == EINTR)
56 clearerr((FILE *) fp);
58 /* If we made it non-blocking for this, switch it back */
59 if (!(flags & O_NONBLOCK)) {
60 while (fcntl(fileno((FILE *) fp), F_SETFL, flags) < 0) {
61 /* still highly unlikely */
71 if (errno == EAGAIN || feof((FILE *) fp)) {
72 clearerr((FILE *) fp);
79 } else if (ungetc(c, (FILE *) fp) == EOF) {