diff options
author | Vadim Godunko <godunko@adacore.com> | 2019-08-21 08:31:20 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-08-21 08:31:20 +0000 |
commit | 5eb349352b984be67d56a0e54cbd3ceace04083b (patch) | |
tree | f30331d48cdf6701e5ea6d17cd047fe2780fd6b1 | |
parent | 7c2a44aebbdcbd1c250b99541b25afd1dfcb60e8 (diff) | |
download | gcc-5eb349352b984be67d56a0e54cbd3ceace04083b.zip gcc-5eb349352b984be67d56a0e54cbd3ceace04083b.tar.gz gcc-5eb349352b984be67d56a0e54cbd3ceace04083b.tar.bz2 |
[Ada] Improve detection of end of the process by GNAT.Expect
'read' system call may be interrupted by signal with 'errno' is set to
EINTER. In this case, re-try a few times.
2019-08-21 Vadim Godunko <godunko@adacore.com>
gcc/ada/
* libgnat/g-expect.adb (Expect_Internal): Attempt to read
several times when 'read' returns non-positive.
From-SVN: r274791
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/libgnat/g-expect.adb | 16 |
2 files changed, 16 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 15fcd26..53ecd1a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-08-21 Vadim Godunko <godunko@adacore.com> + + * libgnat/g-expect.adb (Expect_Internal): Attempt to read + several times when 'read' returns non-positive. + 2019-08-21 Piotr Trojanek <trojanek@adacore.com> * einfo.adb (Is_Discriminal): Remove extra parens. diff --git a/gcc/ada/libgnat/g-expect.adb b/gcc/ada/libgnat/g-expect.adb index 8601f6b..21c7913 100644 --- a/gcc/ada/libgnat/g-expect.adb +++ b/gcc/ada/libgnat/g-expect.adb @@ -692,15 +692,21 @@ package body GNAT.Expect is Buffer_Size := 4096; end if; - N := Read (Descriptors (D).Output_Fd, Buffer'Address, - Buffer_Size); + -- Read may be interrupted on Linux by a signal and + -- need to be repeated. We don't want to check for + -- errno = EINTER, so just attempt to read a few + -- times. + + for J in 1 .. 3 loop + N := Read (Descriptors (D).Output_Fd, + Buffer'Address, Buffer_Size); + + exit when N > 0; + end loop; -- Error or End of file if N <= 0 then - -- ??? Note that ddd tries again up to three times - -- in that case. See LiterateA.C:174 - Close (Descriptors (D).Input_Fd); Descriptors (D).Input_Fd := Invalid_FD; Result := Expect_Process_Died; |