Subject: bug#59586: Conflicting types for 'wait' in binutils test program

From: Jacob Bachmeyer <[email-masked]>
Date: Fri, 25 Nov 2022 21:42:42 -0600

John David Anglin wrote:
> https://sourceware.org/bugzilla/show_bug.cgi?id=29828
>
> [...]
>
> In dejagnu.h, we have:
>
> void
> wait (void)
> {
> #ifdef_DEJAGNU_WAIT_
>   fd_set rfds;
>   struct timeval tv;
>
>   FD_ZERO (&rfds);
>   tv.tv_sec = 0;
>   tv.tv_usec = 1;
>
>   select (0, &rfds, NULL, NULL, &tv);
> #endif
> }
>
> In fixed stdlib.h, we have:
> #ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED
> # include <sys/wait.h>     /* For required W* macros */
>
> Seems like a dejagnu bug. dejagnu-1.6.3 is installed.

The expectation (long before my time) seems to have been that DejaGnu 
unit test programs would not have subprocesses and therefore would not 
need <sys/wait.h> at all.  That said, name collisions with symbols 
defined by POSIX are clearly a bad idea.

The entire _DEJAGNU_WAIT_ feature appears to be an attempt at a 
workaround for an Expect caveat now documented in the DejaGnu manual.  
(Sub-subheading "Priority of Expect patterns" in the node "Writing a 
test case")  Since it appears to be a timing solution to a sequencing 
problem, I am likely to simply remove it.

This has been added to the list of other issues with dejagnu.h that are 
to be fixed prior to the 1.6.4 release.  The 1.6.4 release will be the 
first with significant attention to the C/C++ unit test facility since I 
became the lead maintainer for DejaGnu; there are also some current 
thread-safety issues that need to be addressed.

Thank you for reporting this issue.

-- Jacob