GNU bug report logs - #10466
MSYS problem with redirects

Previous Next

Package: automake;

Reported by: Peter Rosin <peda <at> lysator.liu.se>

Date: Mon, 9 Jan 2012 11:31:01 UTC

Severity: minor

Tags: patch

Done: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 10466 <at> debbugs.gnu.org (full text, mbox):

From: Peter Rosin <peda <at> lysator.liu.se>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: 10466 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: [PATCH] tests: improve diagnostics when write(2) fails (was:
	bug#10466: MSYS problem with redirects)
Date: Mon, 23 Jan 2012 09:48:15 +0100
Stefano Lattarini skrev 2012-01-09 20:32:
> On 01/09/2012 12:29 PM, Peter Rosin wrote:
>> 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?

Like this (for master)?

Cheers,
Peter


From a8265beb4490e9188358d6e761da33ae326aff41 Mon Sep 17 00:00:00 2001
From: Peter Rosin <peda <at> lysator.liu.se>
Date: Mon, 23 Jan 2012 09:18:46 +0100
Subject: [PATCH] tests: improve diagnostics when write(2) fails

MinGW programs can't redirect file descriptor 9, they can only redirect
stdin, stdout and stderr.  So, improve the information in the test log.

See automake bug#10466.

* tests/parallel-tests-fd-redirect.test (baz.c, zardoz.c): Check the
return value from the write(2) call, and report detected errors.
---
 tests/parallel-tests-fd-redirect.test |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/tests/parallel-tests-fd-redirect.test b/tests/parallel-tests-fd-redirect.test
index 73a134e..8b16378 100755
--- a/tests/parallel-tests-fd-redirect.test
+++ b/tests/parallel-tests-fd-redirect.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 2012 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -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
 
-- 
1.7.5.1





This bug report was last modified 13 years and 174 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.