Hello, Please consider the following testcase:
------ begin weirdio.c ------- #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { int rc; char buf[1024]; char *s = "read() done\n"; for(rc=1;rc>0;) { rc = read(0, buf, sizeof(buf) - 1); // sleep(0); temporarily uncommented write(1, s, (size_t)strlen(s)); } } ------- end weirdio.c ------- when compiled with "gcc -o weirdio weirdio.c" it behaves as expected: ----------------------------- [EMAIL PROTECTED] ~/weirdio $ ./weirdio $ ./weirdio aaa <--- "Return" key hit on the keyboard read() done aaa <--- "Return" key hit on the keyboard read() done bbb <--- "Return" key hit on the keyboard read() done <--- EOF (Ctrl-D) hit on the keyboard read() done <--- last write() duly executed [EMAIL PROTECTED] ~/weirdio $ ----------------------------- However, compiling with "gcc -mno-cygwin -o weirdio weirdio.c" two strange things happen: 1. Only when executed inside a cygwin window (at the bash prompt), the first time "read()" returns as if someone had hit the "Return" key (further investigation with gdb revealed that read() returned 1 and placed one \n character in the buffer). 2. Either at the bash prompt, or in a plain DOS window (under Win98SE) the last "read() done" after EOF (which now is Ctrl-Z) is NOT printed. BUT, it is duly printed if the "sleep(0)" (or sleep with any other argument) is uncommented! Unfortunately, I have no MSVC++ compiler, so I can't see what happens compiling with the tools of the Evil Empire. Any idea? Enzo -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/