[B20.1] stdio and timing issues

Bradley A. Town townba@ix.netcom.com
Thu Feb 4 07:55:00 GMT 1999

I am having some trouble with stdin and timing.

1) It sometimes misses printing a line.
2) Whatever clock() uses for timing appears to not count the time it
waits for user input with, for example, getc.
3) Pressing Ctrl+Z for the input seems to kill stdin routines.  Ctrl+C
doesn't even kill it then.

I have B20.1 running under WinNT 4.0 SP4 with CYGWIN set to `tty' and
TERM set to `pcansi'.  I've tried the latest coolview and different TERM
settings, to no avail.

I'm including an example program below.  It does what I'd expect under
Mingw32 and DJGPP, but it has the aforementioned issues under Cygwin.

I would appreciate any help on this.  Thanks!


--- cut here ---
#include <stdio.h>
#include <time.h>

#define TWOLINES

/* Input
   Expects the user to press Enter.

   Prints the start clock(), the end clock(), and the difference in

   Cygwin issues
   It sometimes misses printing the second line.  When TWOLINES is
     it usually prints both, but not always.  When it isn't defined, it
     usually doesn't print a line.  (Strange problem with stdout?)
   The end clock() printed is always nearly the same.  Defining
     shows that it does pause after receiving an Enter; however, it
     appear to count the time waiting for user input.  (Different
     than djgpp and mingw32.)
   Pressing Ctrl+Z for the input seems to kill the stdin routine.
     doesn't even kill it then; I have to use Task Manager.

int main()
 clock_t clkStart = clock();
 clock_t clkEnd;
 int i;

 i = getc(stdin);

 for (i = 0; i < EMPTYLOOP; i++)

 clkEnd = clock();

 printf("%d -> %d: "
  "%f seconds.\n",
  clkStart, clkEnd, (float)(clkEnd - clkStart) / CLOCKS_PER_SEC);

 return 0;
--- cut here ---

More information about the Cygwin mailing list