[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10466: MSYS problem with redirects
From: |
Stefano Lattarini |
Subject: |
bug#10466: MSYS problem with redirects |
Date: |
Mon, 09 Jan 2012 20:32:42 +0100 |
On 01/09/2012 12:29 PM, Peter Rosin wrote:
> Hi!
>
> parallel-tests-fd-redirect.test fails on MSYS, and I think
> the cause is that the write (9, ...) simply doesn't work for
> MinGW programs (baz.exe and qux.test.exe). It works for the
> shell scripts (foo.sh and bar) since /bin/sh is an MSYS
> program and thus is a lot more POSIXy. But redirecting from
> the MinGW world to the MSYS world in this manner is simply
> not possible, I think. I think that will only work for
> fd 0,1 and 2 (but I'm not 100% sure).
>
So I guess even something like this would fail:
int main (void)
{
return (system("echo bazbazbaz >&9") == 0);
}
right? If yes, the solution might be splitting
p'arallel-tests-fd-redirect.test'
into two tests, and make the one testing the redirection from C skip on
MinGW/MSYS.
> Also, including unistd.h will not work for non-ANSI systems,
> MinGW provides a half-baked unistd.h but MSVC does not.
> MSVC has its write() in io.h, but it will probably suffer
> from the same problem with a dysfunctional fd 9.
> With this diff:
>
> diff --git a/tests/parallel-tests-fd-redirect.test
> b/tests/parallel-tests-fd-red
> index 73a134e..5728014 100755
> --- a/tests/parallel-tests-fd-redirect.test
> +++ b/tests/parallel-tests-fd-redirect.test
> @@ -65,20 +65,26 @@ END
> chmod a+x foo.sh bar
>
> cat > baz.c <<'END'
> +#include <stdio.h>
> #include <unistd.h>
> int main (void)
> {
> - write (9, " bazbazbaz\n", 11);
> - return 0;
> + ssize_t res = write (9, " bazbazbaz\n", 11);
> + if (res < 0)
> + perror("write failed");
> + return res != 11;
> }
> END
>
> cat > zardoz.c <<'END'
> +#include <stdio.h>
> #include <unistd.h>
> int main (void)
> {
> - write (9, " quxquxqux\n", 11);
> - return 0;
> + ssize_t res = write (9, " quxquxqux\n", 11);
> + if (res < 0)
> + perror("write failed");
> + return res != 11;
> }
> END
>
BTW, this change might be independently useful in catching other potential
unexpected write failures; would you feel like cooking it in a proper patch?
> the embedded test suite goes from 4 PASS to 2 PASS / 2 FAIL,
> and this in the log files:
>
> + cat foo.log
> + cat bar.log
> + cat baz.log
> write failed: Bad file descriptor
> + cat qux.log
> write failed: Bad file descriptor
>
> supporting the above beliefs.
>
> Cheers,
> Peter
>
Thanks,
Stefano