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/4/2006 5:30 PM:
> I still need to add more tests from the mailing lists, but here is a group of 
> tests that expose current shortfalls in handling closed fds.

And I backported the detection of stderr write failures to the branch.

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

	* src/m4.c (usage, main): Detect write failures to stderr.
	* src/builtin.c (m4_m4exit): Likewise.
	* NEWS: Document this.

- --
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

iD8DBQFFKxmC84KuGfSFAYARAu0lAJ9bzrwwEs8fVwown08l/K2AFGQ2KQCgsFS6
gaMyt7iNKH+p23kLpkemcHI=
=k1YF
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch179 (text/plain, 2.4 KB)
Index: NEWS
===================================================================
RCS file: /sources/m4/m4/NEWS,v
retrieving revision 1.1.1.1.2.67
diff -u -p -r1.1.1.1.2.67 NEWS
--- NEWS	10 Oct 2006 03:27:15 -0000	1.1.1.1.2.67
+++ NEWS	10 Oct 2006 03:52:52 -0000
@@ -11,6 +11,8 @@ Version 1.4.8 - ?? ??? 2006, by ??  (CVS
   to remove the default limit of 1024.  However, it is still possible that
   heavily nested input can cause abrupt program termination due to stack
   overflow.
+* Problems encountered when writing to standard error, such as with the
+  `errprint' macro, now always cause a non-zero exit status.
 
 Version 1.4.7 - 25 September 2006, by Eric Blake  (CVS version 1.4.6a)
 
Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.40
diff -u -p -r1.1.1.1.2.40 builtin.c
--- src/builtin.c	11 Sep 2006 13:17:21 -0000	1.1.1.1.2.40
+++ src/builtin.c	10 Oct 2006 03:52:52 -0000
@@ -1301,6 +1301,8 @@ m4_m4exit (struct obstack *obs, int argc
       if (exit_code == 0)
 	exit_code = EXIT_FAILURE;
     }
+  if (close_stream (stderr) != 0 && exit_code == 0)
+    exit_code = EXIT_FAILURE;
   if (exit_code == 0 && retcode != 0)
     exit_code = retcode;
   exit (exit_code);
Index: src/m4.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/m4.c,v
retrieving revision 1.1.1.1.2.32
diff -u -p -r1.1.1.1.2.32 m4.c
--- src/m4.c	10 Oct 2006 02:56:18 -0000	1.1.1.1.2.32
+++ src/m4.c	10 Oct 2006 03:52:52 -0000
@@ -207,6 +207,8 @@ mismatch, or whatever value was passed t
 
   if (close_stream (stdout) != 0)
     M4ERROR ((EXIT_FAILURE, errno, "write error"));
+  if (close_stream (stderr) != 0)
+    exit (EXIT_FAILURE); /* Can't really do much else without stderr.  */
   exit (status);
 }
 
@@ -429,7 +431,9 @@ Written by Rene' Seindal.\n\
 ", stdout);
 
 	 if (close_stream (stdout) != 0)
-	    M4ERROR ((EXIT_FAILURE, errno, "write error"));
+	   M4ERROR ((EXIT_FAILURE, errno, "write error"));
+	 if (close_stream (stderr) != 0)
+	   exit (EXIT_FAILURE);
 	 exit (EXIT_SUCCESS);
 	break;
 
@@ -569,5 +573,7 @@ Written by Rene' Seindal.\n\
 
   if (close_stream (stdout) != 0)
     M4ERROR ((EXIT_FAILURE, errno, "write error"));
+  if (close_stream (stderr) != 0)
+    exit (EXIT_FAILURE); /* Can't really do much else without stderr.  */
   exit (retcode);
 }
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.