This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] GNAT.Expect (Expect_Internal): Try to call 'poll' few times
- From: Pierre-Marie de Rodat <derodat at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Vadim Godunko <godunko at adacore dot com>
- Date: Tue, 17 Sep 2019 04:06:33 -0400
- Subject: [Ada] GNAT.Expect (Expect_Internal): Try to call 'poll' few times
'poll' returns -1 in case of any error (including interruption by a
signal), so call need to be repeated few times to avoid false failures.
Tested on x86_64-pc-linux-gnu, committed on trunk
2019-09-17 Vadim Godunko <godunko@adacore.com>
gcc/ada/
* libgnat/g-expect.adb (Expect_Internal): Try to call 'poll' few
times.
--- gcc/ada/libgnat/g-expect.adb
+++ gcc/ada/libgnat/g-expect.adb
@@ -679,8 +679,17 @@ package body GNAT.Expect is
-- Loop until we match or we have a timeout
loop
- Num_Descriptors :=
- Poll (Fds'Address, Fds_Count, Timeout, D'Access, Is_Set'Address);
+ -- Poll 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 call Poll a few times.
+
+ for J in 1 .. 3 loop
+ Num_Descriptors :=
+ Poll
+ (Fds'Address, Fds_Count, Timeout, D'Access, Is_Set'Address);
+
+ exit when Num_Descriptors /= -1;
+ end loop;
case Num_Descriptors is