vi: flush trace to disk early

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

vi: flush trace to disk early

Martijn van Duren-5
Hello tech@,

When debugging some crashes in vi it can come in handy if TRACE calls
are actually send to disk before the crash.

This shouldn't be a problem, since we're running debugging code anyway.

OK?

martijn@

Index: common/main.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.40
diff -u -p -r1.40 main.c
--- common/main.c 3 Jul 2017 07:01:14 -0000 1.40
+++ common/main.c 10 Nov 2017 11:13:56 -0000
@@ -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. */
Index: common/util.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/util.c,v
retrieving revision 1.15
diff -u -p -r1.15 util.c
--- common/util.c 27 May 2016 09:18:11 -0000 1.15
+++ common/util.c 10 Nov 2017 11:13:56 -0000
@@ -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);

Reply | Threaded
Open this post in threaded view
|

Re: vi: flush trace to disk early

Todd C. Miller
On Fri, 10 Nov 2017 12:15:18 +0100, Martijn van Duren wrote:

> When debugging some crashes in vi it can come in handy if TRACE calls
> are actually send to disk before the crash.
>
> This shouldn't be a problem, since we're running debugging code anyway.

OK millert@

 - todd