Re: add some fd tests to head

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 10/6/2006 12:24 PM:
> Finally, all the new tests now pass[*][**] on cygwin with this patch.
> 
> [*] if you use my proposed patch to gnulib clean-temp, not yet committed
> as of this writing
> [**] cygwin 1.5.21 and earlier had a bug in popen: if stdout is closed,
> popen fails to create a pipe.  This is fixed in cygwin CVS.

And once I upgraded to a cygwin snapshot, I discovered I still had a bug
in the test.  Plus, gnulib changed to make it possible to detect failure
in cleaning up the temp directory (unlikely, but if we print to stderr
stating that a temp file couldn't be deleted, the exit status might as
well reflect that).

2006-10-06  Eric Blake  <[email protected]>

	* m4/output.c (cleanup_tmpfile): Exit nonzero on failure to clean
	up.
	* tests/others.at (stdout closed): Fix final check.

- --
Life is short - so eat dessert first!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFJzWh84KuGfSFAYARAne3AJ45HiuzYB2lYkH2VdtnAtJcJbCnXQCaApEe
YtlG2gb7+gB3sRLiM4R1jX4=
=vXT7
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch177 (text/plain, 1.7 KB)
Index: m4/output.c
===================================================================
RCS file: /sources/m4/m4/m4/output.c,v
retrieving revision 1.31
diff -u -p -r1.31 output.c
--- m4/output.c	6 Oct 2006 18:24:31 -0000	1.31
+++ m4/output.c	7 Oct 2006 05:01:44 -0000
@@ -30,6 +30,7 @@
 
 #include "binary-io.h"
 #include "clean-temp.h"
+#include "exitfail.h"
 #include "xvasprintf.h"
 
 /* Define this to see runtime debug output.  Implied by DEBUG.  */
@@ -117,11 +118,13 @@ m4_output_exit (void)
 }
 
 /* Clean up any temporary directory.  Designed for use as an atexit
-   handler.  */
+   handler, where it is not safe to call exit() recursively; so this
+   calls _exit if a problem is encountered.  */
 static void
 cleanup_tmpfile (void)
 {
-  cleanup_temp_dir (output_temp_dir);
+  if (cleanup_temp_dir (output_temp_dir) != 0)
+    _exit (exit_failure);
 }
 
 /* Create a temporary file open for reading and writing in a secure
Index: tests/others.at
===================================================================
RCS file: /sources/m4/m4/tests/others.at,v
retrieving revision 1.22
diff -u -p -r1.22 others.at
--- tests/others.at	6 Oct 2006 18:24:31 -0000	1.22
+++ tests/others.at	7 Oct 2006 05:01:44 -0000
@@ -543,11 +543,13 @@ AT_DATA([in.m4], [[syscmd(`cat')dnl
 AT_CHECK_M4([>&-], [0], [], [experr], [in.m4])
 
 dnl command line input file must not collide with closed stdout
-AT_DATA([in.m4], [[syscmd(`cat <&1 >&2')
+AT_DATA([in.m4], [[syscmd(`cat <&1 >&2')dnl
 dnl this line should not be read by cat
 ]])
 AT_CHECK_M4([in.m4 >&-], [0], [], [stderr])
-AT_CHECK([sed -ne '/should not be read/p' stderr], [0])
+AT_CHECK([sed -e 's/.*\(Bad file descriptor\)$/\1/' stderr], [0],
+[[Bad file descriptor
+]])
 
 AT_CLEANUP
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.