Re: failure with HEAD: stdin seekable

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

According to Eric Blake on 12/16/2006 12:42 PM:
> Oops - fd 0 was never closed, let alone reset to the last unbuffered
> offset, so the cat process is starting from the wrong offset.  It is this
> same bug that is breaking the m4 test.  I will file a glibc bug report.

Well, Ulrich claimed the bug is in m4 (and sed, and ...), not glibc (and
while I disagree, based on the number of apps that would simultaneously be
fixed if he were to change glibc, I know better than to argue with him):
http://sources.redhat.com/bugzilla/show_bug.cgi?id=3746

> 
> In the meantime, gnulib can probably work around this bug.  m4 already
> uses the closeout module.  I think close_stdout be updated to flush and
> close stdin for the benefit of implementations (like glibc, or like cygwin
> 1.5.22 and earlier) where exit() is broken because it fails to reset the
> fd offset of seekable stdin.

It also turns out that I didn't fully port the patch from the branch,
where this was working correctly.

2006-12-16  Eric Blake  <[email protected]>

	* src/main.c (main): Check for errors when closing stdin.
	* modules/m4.c (m4exit): Missed part of previous patch: flush
	stdin before a successful exit.
	Reported by Ralf Wildenhues.

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

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

iD8DBQFFhMWu84KuGfSFAYARAoKiAJ4qUkOGbbvvybawtZwEkdey4/X8ygCfQIYL
bA0lcHWw4W7kcIKD9fsbHxE=
=Kv9I
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch215 (text/plain, 1.3 KB)
Index: src/main.c
===================================================================
RCS file: /sources/m4/m4/src/main.c,v
retrieving revision 1.103
diff -u -p -r1.103 main.c
--- src/main.c	14 Nov 2006 05:58:01 -0000	1.103
+++ src/main.c	17 Dec 2006 04:17:05 -0000
@@ -776,7 +776,7 @@ main (int argc, char *const *argv, char 
      stream and detect any errors it might have encountered.  Close
      stdin if we read from it, to detect any errors.  */
   m4_debug_set_output (context, NULL);
-  if (read_stdin && fclose (stdin) == EOF)
+  if (read_stdin && close_stream (stdin) == EOF)
     m4_error (context, 0, errno, _("error closing stdin"));
 
   exit_status = m4_get_exit_status (context);
Index: modules/m4.c
===================================================================
RCS file: /sources/m4/m4/modules/m4.c,v
retrieving revision 1.94
diff -u -p -r1.94 m4.c
--- modules/m4.c	15 Dec 2006 04:23:48 -0000	1.94
+++ modules/m4.c	17 Dec 2006 04:17:05 -0000
@@ -839,6 +839,7 @@ M4BUILTIN_HANDLER (m4exit)
   /* Change debug stream back to stderr, to force flushing debug
      stream and detect any errors.  */
   m4_debug_set_output (context, NULL);
+  m4_sysval_flush (context);
 
   /* Check for saved error.  */
   if (exit_code == 0 && m4_get_exit_status (context) != 0)
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.