Remove the assumption that file descriptor 1 is readable. It can be if
it, or where it was dup(2)'d from, was opened read/write, e.g. on
/dev/tty. But it can easily be arranged with shell re-direction that it
isn't, and then the read(2) fails. Pass 0, standard input's file
descriptor, instead. Don't use fileno(stdin) as I can't think of a need
to support that being non-zero, but its use makes the reader think it
might. Bug pre-dates git.
}
fflush (stdout);
buf[0] = 0;
- if (read (fileno (stdout), buf, sizeof(buf)) < 0) {
+ if (read(0, buf, sizeof(buf)) < 0) {
advise ("stdout", "read");
}
}
putchar ('\007');
fflush (stdout);
buf[0] = 0;
- if (read (fileno (stdout), buf, sizeof(buf)) < 0) {
+ if (read(0, buf, sizeof(buf)) < 0) {
advise ("stdout", "read");
}
if (strchr(buf, '\n')) {