From: fujieda AT jaist DOT ac DOT jp (Kazuhiro Fujieda) Subject: fhandler_console bug 11 Jan 1999 04:31:07 -0800 Message-ID: Mime-Version: 1.0 (generated by SEMI MIME-Edit 0.100 - "Shijima") Content-Type: text/plain; charset=US-ASCII To: cygwin32-developers AT cygnus DOT com The following program is hanged up when Return and ^Z are typed continuously in notty mode on Win95. #include main() { int ch; while ((ch = fgetc(stdin)) != EOF) { printf("ch = %02x\n", ch); } } The reason of it is in fhandler_console.cc:1143-1157. 1142: copied_chars = 0x12345678; 1143: if ((res = ReadFile (hndl, buf, lenin, &copied_chars, NULL)) && 1144: copied_chars == 0x12345678) When ^Z is typed, ReadFile catch the EOF and set copied_char is 0. But the succeeding code take no account of this case. On Win95, ReadFile doesn't modify the contents of buf in this case, so buf[0] is still '\n' and the program is crushed by the following code. 1153: if (!looped++ && buf[0] == '\n') 1154: { 1155: if (!--copied_chars) 1156: continue; 1157: memcpy (buf, buf + 1, copied_chars); ____ | AIST Kazuhiro Fujieda | HOKURIKU School of Information Science o_/ 1990 Japan Advanced Institute of Science and Technology