Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/m4 Try not to lose error output with --error-output.



details:   https://anonhg.NetBSD.org/src/rev/253d9e8618d1
branches:  trunk
changeset: 1011264:253d9e8618d1
user:      uwe <uwe%NetBSD.org@localhost>
date:      Wed Jun 24 16:49:30 2020 +0000

description:
Try not to lose error output with --error-output.

Try to avoid the trap we set up ourselves while avoiding freopen(3).
When exit flushes and closes open streams it may close sfp first and
when it comes about to flush and close stderr, the descriptor is
already gone and we lose any buffered error output.  This actually
happens on some hosts, breaking --trace output used by autoconf.

diffstat:

 usr.bin/m4/main.c |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r 9c1a4df6cf32 -r 253d9e8618d1 usr.bin/m4/main.c
--- a/usr.bin/m4/main.c Wed Jun 24 16:29:34 2020 +0000
+++ b/usr.bin/m4/main.c Wed Jun 24 16:49:30 2020 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */
-/*     $NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $       */
+/*     $NetBSD: main.c,v 1.49 2020/06/24 16:49:30 uwe Exp $    */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #include "nbtool_config.h"
 #endif
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.49 2020/06/24 16:49:30 uwe Exp $");
 #include <assert.h>
 #include <signal.h>
 #include <getopt.h>
@@ -274,6 +274,17 @@
                        }
                        fclose(stderr);
                        memcpy(stderr, sfp, sizeof(*sfp));
+                       /*
+                        * XXX: try to avoid the trap set up by the
+                        * kludge above.  When exit flushes and closes
+                        * open streams it may close sfp first and
+                        * when it comes about to flush and close
+                        * stderr, the descriptor is already gone and
+                        * we lose any buffered output.  This actually
+                        * happens on some hosts, breaking autoconf
+                        * tracing.
+                        */
+                       setvbuf(stderr, (char *)NULL, _IOLBF, 0);
                        break;
                case 'F':
                        freeze = optarg;



Home | Main Index | Thread Index | Old Index