On Monday 22 June 2026 10:13:30 Kirill Makurin wrote:
> From 3fb6aa08f1cdc6a62c4a553391220c6740c0cf69 Mon Sep 17 00:00:00 2001
> From: Kirill Makurin <[email protected]>
> Date: Mon, 22 Jun 2026 18:59:43 +0900
> Subject: [PATCH 4/4] crt: tests: update t_assert
> 
> Wait until the child process termintaes before reading from the pipe;
> this allows to read complete output produces by the child process.
> 
> Print data read from the pipe to stdout; this allows to examine assertion
> message printed by the child process.
> 
> Signed-off-by: Kirill Makurin <[email protected]>
> ---
>  mingw-w64-crt/testcases/t_assert.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/mingw-w64-crt/testcases/t_assert.c 
> b/mingw-w64-crt/testcases/t_assert.c
> index e66c406e8..6b603ad35 100644
> --- a/mingw-w64-crt/testcases/t_assert.c
> +++ b/mingw-w64-crt/testcases/t_assert.c
> @@ -35,14 +35,15 @@ int main(int argc, char *argv[]) {
>  
>          assert(process != -1);
>  
> +        /* wait until child process exits */
> +        assert(_cwait(&exit_code, process, _WAIT_CHILD) == process);
> +        assert(exit_code != 0);
> +
>          size = read(pipefd[0], buf, sizeof(buf));
>          close(pipefd[0]);
>          assert(size > 0); /* some data were written by child process */
>          assert(strnlen(buf, sizeof(buf)) > 0);
> -
> -        /* wait until child process exits */
> -        assert(_cwait(&exit_code, process, _WAIT_CHILD) == process);
> -        assert(exit_code != 0);
> +        write (STDOUT_FILENO, buf, size);
>  
>          return 0;
>      }
> -- 
> 2.51.0.windows.1
> 

I think that this is wrong change. Writing to the pipe can hung
indefinitely if there is no active reader, so the process does not have
to finish. Instead we should first read data from pipe (to make writer
on other side to success and allow it to finish successfully).

Adding "write (STDOUT_FILENO, buf, size);" is of course a good improvement.

Anyway, you have an extra space between "write" and "(" which is not in
other function calls in this file.


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to