Re: pgbench on mingw needs fflush - Mailing list pgsql-patches

From ITAGAKI Takahiro
Subject Re: pgbench on mingw needs fflush
Date
Msg-id 20070313163915.60A4.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Whole thread Raw
In response to Re: pgbench on mingw needs fflush  (Tatsuo Ishii <ishii@sraoss.co.jp>)
Responses Re: pgbench on mingw needs fflush  (Magnus Hagander <magnus@hagander.net>)
List pgsql-patches
Tatsuo Ishii <ishii@sraoss.co.jp> wrote:

> Can we distinguish mingw case from others so that we could ifdef out
> the extra fflush()?
> > The buffered stderr might be a bug of mingw

After a little research, I found that MSDN says the buffered stderr is
a specifications on Windows somehow, not a bug.

setvbuf() is better solution for the problem.
This is more simple and no need to use ifdef.



*** pgbench.c.orig    Mon Jan 22 11:17:30 2007
--- pgbench.c    Tue Mar 13 17:01:12 2007
*************** main(int argc, char **argv)
*** 1184,1189 ****
--- 1184,1192 ----

      char        val[64];

+     /* stderr is buffered on Win32. */
+     setvbuf(stderr, NULL, _IONBF, 0);
+
      if ((env = getenv("PGHOST")) != NULL && *env != '\0')
          pghost = env;
      if ((env = getenv("PGPORT")) != NULL && *env != '\0')

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center



pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: guc patch: Make variables fall back to default values
Next
From: Gregory Stark
Date:
Subject: Re: guc patch: Make variables fall back to default values