Subject: B20.1: getc(stdin) half-second delay under cmd.exe but not in bash
From: "IO ERROR" <[email-masked]>
To: <[email-masked]>
Cc: <[email-masked]>
Date: Thu, 4 Feb 1999 01:38:17 -0600

I've searched the archives for an issue similar to this, but to no avail.  I
have a program which reads from stdin, with the following termios settings:

~(INLCR | IGNCR | ICRNL)
IXOFF | IXON | IXANY
~(ONLCR | OCRNL)
~(ISIG | ICANON | ECHO)
VMIN = 1
VTIME = 0

and I have called:  setvbuf(stdin, NULL, _IONBF, 0)

I use fgetc(stdin) for single-character input, and select() to determine
when input is available.  When I run my program under bash, it works fine;
however, when I run it under cmd.exe or from a shortcut on my desktop, there
is a cumulative delay of one-half second from the time the key is pressed
and the time fgetc() returns.  Cumulative meaning if I type several
characters at once, fgetc() waits half a second between each of them.

I have debugged this and determined that select() returns immediately and
the program is hanging in fgetc(), but as I have neither the space nor time
to look at the cygwin source code, I'm unable to go any further with this.
Due to the complexity of the program I was unable to include a test case.

System is CYGWIN95_4.0 OVERSEAS 20.1 (0.3/1/1) 1998-12-3 20:39:18 i486
unknown

Output from cygcheck -s -v -r:

Cygnus Win95/NT Configuration Diagnostics
Current System Time: Thu Feb 04 01:32:39 1999

Win95 Ver 4.0 build 67109975  B

Path:   /USR/CYGWIN~1/H-I586~1/BIN
        /PROGRA~1/ACCESS~1
        /WINDOWS
        /WINDOWS/COMMAND

SysDir: C:\WINDOWS\SYSTEM
WinDir: C:\WINDOWS

!C: = `C:\client-2.1'
TMP = `C:\WINDOWS\TEMP'
TEMP = `C:\WINDOWS\TEMP'
PROMPT = `$p$g'
WINBOOTDIR = `C:\WINDOWS'
COMSPEC = `C:\WINDOWS\COMMAND.COM'
WINDIR = `C:\WINDOWS'
CMDLINE = `cygcheck -s -v -r '
TERM = `cygwin'

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrd
er\Start Menu\&Programs\Cygnus Solutions
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrd
er\Start Menu\&Programs\Cygnus Solutions\Menu
  (default) = (unsupported type)
HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\00
  (default) = `\\.\tape1:'
  unix = `/dev/st1'
  fbinary = 0x00000000
  fsilent = 0x00000001
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\01
  (default) = `\\.\tape0:'
  unix = `/dev/st0'
  fbinary = 0x00000000
  fsilent = 0x00000001
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\02
  (default) = `\\.\b:'
  unix = `/dev/fd1'
  fbinary = 0x00000000
  fsilent = 0x00000001
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\03
  (default) = `\\.\a:'
  unix = `/dev/fd0'
  fbinary = 0x00000000
  fsilent = 0x00000001
HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\04
  (default) = `C:'
  unix = `/'
  fbinary = 0x00000000
  fsilent = 0x00000000
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cygnu
s Cygwin B20
  (default) = `C:\WINDOWS\IsUninst.exe -fc:\usr\cygwin-b20\Uninst.isu'
  DisplayName = `Cygwin B20'
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin B20
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin B20\B20.1
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\GNUPro
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\GNUPro\i586-cygwin32
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus
Solutions\GNUPro\i586-cygwin32\i586-cygwin32
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus
Solutions\GNUPro\i586-cygwin32\i586-cygwin32\cygwin-B20.1
  (default) = `c:\usr\cygwin-b20'
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\00
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\01
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\02
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\03
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\04
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\05
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\06
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\07
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\08
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\09
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\0A
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\0B
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\0C
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\0D
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\0E
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\0F
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\10
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\11
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\12
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\13
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\14
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\15
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\16
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\17
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\18
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\19
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\1A
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\1B
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\1C
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
setup\b15.0\mounts\1D

a:\ fd           N/A    N/A
c:\ hd  FAT32    770Mb  34% CP    UN

C:          /         native  text!=binary
\\.\a:      /dev/fd0  native  text!=binary
\\.\b:      /dev/fd1  native  text!=binary
\\.\tape0:  /dev/st0  native  text!=binary
\\.\tape1:  /dev/st1  native  text!=binary

Found: C:\USR\CYGWIN~1\H-I586~1\BIN\bash.exe
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\cat.exe
Not Found: cpp (good!)
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\find.exe
Found: C:\WINDOWS\COMMAND\find.exe
Warning: C:\USR\CYGWIN~1\H-I586~1\BIN\find.exe hides
C:\WINDOWS\COMMAND\find.exe
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\gcc.exe
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\gdb.exe
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\ld.exe
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\ls.exe
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\make.exe
Found: C:\USR\CYGWIN~1\H-I586~1\BIN\sh.exe
Found: \bin\sh.exe
Warning: C:\USR\CYGWIN~1\H-I586~1\BIN\sh.exe hides \bin\sh.exe

  446k 1998/12/04 .\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=1998/12/3 22:39
  446k 1998/12/04 .\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=1998/12/3 22:39
  371k 1998/12/01 C:\USR\CYGWIN~1\H-I586~1\BIN\cygtcl80.dll - os=4.0 img=1.0
sys=4.0
                  "cygtcl80.dll" v0.0 ts=1998/12/1 2:25
    5k 1998/12/01 C:\USR\CYGWIN~1\H-I586~1\BIN\cygtclpip80.dll - os=4.0
img=1.0
sys=4.0
   10k 1998/12/01 C:\USR\CYGWIN~1\H-I586~1\BIN\cygtclreg80.dll - os=4.0
img=1.0
sys=4.0
                  "cygtclreg80.dll" v0.0 ts=1998/12/1 2:25
  600k 1998/12/01 C:\USR\CYGWIN~1\H-I586~1\BIN\cygtk80.dll - os=4.0 img=1.0
sys=4.0
                  "cygtk80.dll" v0.0 ts=1998/12/1 2:28
  446k 1998/12/04 C:\USR\CYGWIN~1\H-I586~1\BIN\cygwin1.dll - os=4.0 img=1.0
sys=4.0
                  "cygwin1.dll" v0.0 ts=1998/12/3 22:39
Use -h to see help about each section