Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <015501c4290b$96c839e0$0200a8c0@em.noip.com> From: "Enzo Michelangeli" To: Subject: Re: 1.5.9-1: weird console I/O behaviour compiling with -mno-cygwin Date: Fri, 23 Apr 2004 16:18:11 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Quick update: The same testcase, compiled under MSYS 1.0.10 with Mingw gcc (gcc 3.2.3 (mingw special 20030504-1)), does not exhibit the problem No.1, but still shows the No.2 when run in a standard DOS box. When run inside a MSYS window it does not recognize as EOF either Ctrl-Z or Ctrl-D, so the test No.2 can't take place... Enzo ----- Original Message ----- From: "Enzo Michelangeli" To: Sent: Friday, April 23, 2004 10:32 AM Subject: Re: 1.5.9-1: weird console I/O behaviour compiling with -mno-cygwin Hello, Please consider the following testcase: ------ begin weirdio.c ------- #include #include 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: ----------------------------- em AT emnb ~/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 em AT emnb ~/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/