https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82233
--- Comment #21 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
We could do something like
program boom
implicit none
interface
subroutine mywait() bind(c)
end subroutine mywait
end interface
integer :: i,j
character(len=256) :: msg
character(len=:), allocatable :: command
command='notthere'
msg='' ! seems to only be defined if exitstatus.ne.0
! ok -- these work
call execute_command_line(command , wait=.false., exitstat=i, cmdstat=j,
cmdmsg=msg)
if (j /= 0 .or. msg /= '') call abort
call execute_command_line(command , exitstat=i, cmdstat=j,
cmdmsg=msg )
if (j /= 3 .or. msg /= "Invalid command line" ) call abort
msg = ''
call execute_command_line(command , wait=.false., exitstat=i,
cmdmsg=msg )
print *,msg
if (msg /= '') call abort
call execute_command_line(command , exitstat=i, cmdstat=j
)
if (j /= 3) call abort
call execute_command_line(command , wait=.false., exitstat=i
)
call mywait()
end program boom
and
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
/* Wait in a busy loop for any processes that may still be around. */
void mywait()
{
errno = 0;
while (waitpid (-1, NULL, WNOHANG) >= 0)
{
n++;
if (errno != ECHILD)
break;
}
}
but I am not sure that waitpid is available on all systems;
this is more likely to break things than fix things.
What you could to to reduce the amount of noise that you see is
sleep for a second; just insert
CALL SLEEP(1)
before the END statement of the test case, locally in your tree.
This could help. I don't want to do this for everybody (test times
being long enough as they are), but for most cases, this should
be enough.