[Regression, libgfortran] READ from the terminal is stuffed.
Janne Blomqvist
jblomqvi@cc.hut.fi
Wed Oct 12 06:59:00 GMT 2005
On Tue, Oct 11, 2005 at 10:30:17PM +0200, Paul Thomas wrote:
> Janne,
>
> Your patch of 2005/10/07
> (http://gcc.gnu.org/ml/gcc-cvs/2005-10/msg00252.html) has completely
> stuffed READ from the terminal for FC3/i686, with any combination of
> formatted/ unformatted unit=*/unint=5 it just hangs. As far as I can
> tell, file IO is OK.
>
> This hangs at the read statement:
>
> print *, "what's my number?"
> read (5,'(i4)') i
> print *, "you typed ", i
> end
>
> I can use read *, i or read (*,*) i etc., with the same effect. If I
> patch the cvs libgfortran of 2005/10/06, normal service is restored.
Ugh. I'm not at home now, but I think I know what the problem is. I
think the culprit is the change to fd_alloc_r_at () in unix.c. With my
patch, it calls do_read() which calls the read() syscall in a
loop. do_read() does check if the number of bytes read is 0 (EOF
check), and breaks the loop in that case. I suspect that for some
reason the loop doesn't break for you when reading from the terminal,
and thus it hangs.
E.g. could you try backing out this part of the patch for unix.c:
@@ -394,7 +440,7 @@
fd_alloc_r_at (unix_stream * s, int *len, gfc_offset where)
{
gfc_offset m;
- int n;
+ size_t n;
if (where == -1)
where = s->logical_offset;
@@ -416,8 +462,8 @@
if (s->physical_offset != m && lseek (s->fd, m, SEEK_SET) < 0)
return NULL;
- n = read (s->fd, s->buffer + s->active, s->len - s->active);
- if (n < 0)
+ n = s->len - s->active;
+ if (do_read (s, s->buffer + s->active, &n) != 0)
return NULL;
s->physical_offset = where + n;
@@ -502,9 +548,15 @@
}
If this works consider the patch OK:d from me. The rest of my patch
should work as before despite this change, as after this the only
place where do_read() is used is for big unformatted reads, which
obviously don't suffer from weird interactions with the terminal.
--
Janne Blomqvist
More information about the Fortran
mailing list