From 3c952fed3fecfe6aec09d07a5cbad293970da0a0 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 28 Oct 2000 00:21:41 +0000 Subject: * strace.cc (main): Add a '-b' option. --- winsup/utils/strace.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'winsup/utils/strace.cc') diff --git a/winsup/utils/strace.cc b/winsup/utils/strace.cc index 28067214b..334a148d5 100644 --- a/winsup/utils/strace.cc +++ b/winsup/utils/strace.cc @@ -23,6 +23,7 @@ static int numerror = 1; static int usecs = 1; static int delta = 1; static int hhmmss = 0; +static int bufsize = 0; static BOOL close_handle (HANDLE h, DWORD ok); @@ -492,7 +493,8 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile) child->last_usecs = usecs; if (numerror || !output_winerror (ofile, s)) fputs (s, ofile); - fflush (ofile); + if (!bufsize) + fflush (ofile); } static void @@ -575,12 +577,15 @@ main(int argc, char **argv) else pgm++; - while ((opt = getopt (argc, argv, "m:o:fndut")) != EOF) + while ((opt = getopt (argc, argv, "b:m:o:fndut")) != EOF) switch (opt) { case 'f': forkdebug ^= 1; break; + case 'b': + bufsize = atoi (optarg); + break; case 'm': mask = strtoul (optarg, NULL, 16); break; @@ -607,6 +612,9 @@ main(int argc, char **argv) if (!mask) mask = 1; + if (bufsize) + setvbuf (ofile, (char *) alloca (bufsize), _IOFBF, bufsize); + if (!ofile) ofile = stdout; -- cgit v1.2.3