[Bug libfortran/67585] Retry system calls failing with EINTR

2016-10-09 Thread jb at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67585

Janne Blomqvist  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Janne Blomqvist  ---
Fixed on trunk, closing.

[Bug libfortran/67585] Retry system calls failing with EINTR

2016-10-09 Thread jb at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67585

--- Comment #3 from Janne Blomqvist  ---
Author: jb
Date: Sun Oct  9 18:05:56 2016
New Revision: 240902

URL: https://gcc.gnu.org/viewcvs?rev=240902=gcc=rev
Log:
PR 67585 Handle EINTR

Many POSIX systems have the bad habit of not restarting interrupted
syscalls. On these systems it's up to the user to check for an error
with errno == EINTR and restart manually. This patch does this for
libgfortran, so that GFortran users don't have to do it.

2016-10-09  Janne Blomqvist  

PR libfortran/67585
* io/io.h: TEMP_FAILURE_RETRY: Define macro if not found.
* io/unix.c (raw_read): Handle EINTR.
(raw_write): Check for return value -1.
(raw_seek): Handle EINTR.
(raw_tell): Likewise.
(raw_size): Likewise.
(raw_truncate): Likewise.
(raw_close): Likewise.
(buf_flush): Call raw_seek instead of lseek.
(buf_read): Likewise.
(buf_write): Likewise.
(fd_to_stream): Handle EINTR.
(tempfile_open): Likewise.
(regular_file2): Likewise.
(compare_file_filename): Likewise.
(find_file): Likewise.
(inquire_sequential): Likewise.
(inquire_direct): Likewise.
(inquire_formatted): Likewise.

Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/io.h
trunk/libgfortran/io/unix.c

[Bug libfortran/67585] Retry system calls failing with EINTR

2015-09-16 Thread jb at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67585

Janne Blomqvist  changed:

   What|Removed |Added

 Status|WAITING |NEW

--- Comment #2 from Janne Blomqvist  ---
(In reply to Dominique d'Humieres from comment #1)
> > libgfortran should retry system calls failing with EINTR, with the exception
> > of close(). Rationale and further reading e.g. at
> >  https://www.python.org/dev/peps/pep-0475/
> 
> I don't understand what is expected.

Don't worry, I know what needs to be done. I don't have time right now, so I
filed this PR so I don't forget about it. And of course, if somebody else gets
it done before I do it myself, all the better..

> The only place where EINTR is used is
> in raw_write file io/unix.c with a comment
> 
>   /* We must write in a loop since some systems don't restart system
>  calls in case of a signal.  */
> 
> For raw_read, the comment is
> 
>   /* For read we can't do I/O in a loop like raw_write does, because
>  that will break applications that wait for interactive I/O.  */

If you look back in the commit logs, I recall I wrote those comments myself..
FWIW, raw_write does it correctly, and while raw_read can't loop due to how
terminals handle short reads, it should still be fixed to handle EINTR. And
then there's all the other syscalls that can fail with EINTR.


[Bug libfortran/67585] Retry system calls failing with EINTR

2015-09-15 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67585

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2015-09-15
 Ever confirmed|0   |1

--- Comment #1 from Dominique d'Humieres  ---
> libgfortran should retry system calls failing with EINTR, with the exception
> of close(). Rationale and further reading e.g. at
>  https://www.python.org/dev/peps/pep-0475/

I don't understand what is expected. The only place where EINTR is used is in
raw_write file io/unix.c with a comment

  /* We must write in a loop since some systems don't restart system
 calls in case of a signal.  */

For raw_read, the comment is

  /* For read we can't do I/O in a loop like raw_write does, because
 that will break applications that wait for interactive I/O.  */