This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] cygcheck: eprintf + display_error: Do /something/.


Op Fri, 17 Dec 2004 01:19:32 -0500 schreef Christopher Faylor
in <20041217061932.GH26712@trixie.casa.cgf.cx>:
:  On Fri, Dec 17, 2004 at 04:33:10AM +0100, Bas van Gompel wrote:
[...]
: > 	* cygcheck.cc (eprintf): Flush stdout before, and stderr after output,
: > 	when stdout and stderr both don't refer to ttys.
: > 	(display_error): Use eprintf.
:
:   Ok.  I don't see any reason to check for ttyness, then.  If this is an issue
:  then lets just flush stdout prior to doing anything with stderr.  Flushing
:  stderr should always be a no-op.

It isn't (a no-op). (See the snippet in my previous mail.) Is this a
difference between cygwin and mingw, maybe?

:  Or, we could just make stdout always unbuffered.

That would force unbuffered output also when there is no error...

Following is the minimal patch which still works for me.


2004-12-17  Bas van Gompel  <cygwin-patch.buzz@bavag.tmfweb.nl>

	* cygcheck.cc (eprintf): Flush stdout before, and stderr after output.
	(display_error): Use eprintf.


--- cygcheck.cc	18 Nov 2004 05:20:23 -0000	1.64
+++ cygcheck.cc	17 Dec 2004 08:38:06 -0000
@@ -9,6 +9,7 @@
    details. */
 
 #include <stdio.h>
+#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
@@ -102,9 +103,15 @@ void
 eprintf (const char *format, ...)
 {
   va_list ap;
+
+  fflush (stdout);
+
   va_start (ap, format);
   vfprintf (stderr, format, ap);
   va_end (ap);
+
+  fflush (stderr);
+
 }
 
 /*
@@ -114,10 +121,10 @@ static int
 display_error (const char *name, bool show_error = true, bool print_failed = true)
 {
   if (show_error)
-    fprintf (stderr, "cygcheck: %s%s: %lu\n", name,
+    eprintf ("cygcheck: %s%s: %lu\n", name,
 	print_failed ? " failed" : "", GetLastError ());
   else
-    fprintf (stderr, "cygcheck: %s%s\n", name,
+    eprintf ("cygcheck: %s%s\n", name,
 	print_failed ? " failed" : "");
   return 1;
 }


L8r,

Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   /    /   really is |   and false bits entirely.    | mail for
  ) |  |  /    /    a 72 by 4 +-------------------------------+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe "s.u(z)\1.as."    | me. 4^re


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]