summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormartijn <martijn@openbsd.org>2017-11-10 18:31:36 +0000
committermartijn <martijn@openbsd.org>2017-11-10 18:31:36 +0000
commitac99a8fe91823b9734dbdd1b9e025e12cf598f28 (patch)
tree7c5292a5d41e7f2ae17a0cb9baa2ef19d057b536
parentFix a use after free when sending SIGHUP or SIGTERM to vi when in editing (diff)
downloadwireguard-openbsd-ac99a8fe91823b9734dbdd1b9e025e12cf598f28.tar.xz
wireguard-openbsd-ac99a8fe91823b9734dbdd1b9e025e12cf598f28.zip
When tracing is compiled in make sure it flushes its content to disk as
soon as the TRACE function is called. This helps while debugging crashes. Noticed and annoyed by while debugging the SIGTERM crash I just submitted. OK millert@ and tb@
-rw-r--r--usr.bin/vi/common/main.c3
-rw-r--r--usr.bin/vi/common/util.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c
index ccff821ca35..005973728a8 100644
--- a/usr.bin/vi/common/main.c
+++ b/usr.bin/vi/common/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.40 2017/07/03 07:01:14 bentley Exp $ */
+/* $OpenBSD: main.c,v 1.41 2017/11/10 18:31:36 martijn Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -188,6 +188,7 @@ editor(GS *gp, int argc, char *argv[])
}
(void)fprintf(gp->tracefp,
"\n===\ntrace: open %s\n", optarg);
+ fflush(gp->tracefp);
break;
#endif
case 't': /* Tag. */
diff --git a/usr.bin/vi/common/util.c b/usr.bin/vi/common/util.c
index f64bde0a3d5..1ed7f6e13d0 100644
--- a/usr.bin/vi/common/util.c
+++ b/usr.bin/vi/common/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.15 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: util.c,v 1.16 2017/11/10 18:31:36 martijn Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -174,6 +174,7 @@ TRACE(SCR *sp, const char *fmt, ...)
return;
va_start(ap, fmt);
(void)vfprintf(tfp, fmt, ap);
+ fflush(tfp);
va_end(ap);
(void)fflush(tfp);