Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Mon, 1 Oct 2001 22:12:38 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: Bug of select() onto PIPE input. Message-ID: <20011001221238.A11418@redhat.com> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20011001 DOT 230652 DOT 15243440 DOT gotoh AT taiyo DOT co DOT jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011001.230652.15243440.gotoh@taiyo.co.jp> User-Agent: Mutt/1.3.21i Thanks for very the detailed bug report. This should be fixed in the latest snapshot (when it becomes available). The plethora of details and your actual honest-to-god test case helped a great deal in tracking down this problem. If every bug report was like this one, then fixing bugs would almost be a pleasure rather than a chore. Thanks again, cgf On Mon, Oct 01, 2001 at 11:06:52PM +0900, Shun-ichi GOTO wrote: >Hi, cygwin users/developers > >## I'm not ML member, please add Cc: gotoh AT taiyo DOT co DOT jp for this thread. > >I'm using latest snapshot and encounted to problem around select() for >PIPE input. > >The problem is: > select() onto PIPE input returns immediately as "something exist" > on command prompt (cmd.exe) and 4nt. > >Try attached test program "pipe-select.c" and examine following two >case with some version of DLLs. > >(1) pipe-select > >(2) cat - | pipe-select > >With good DLL, (1) waits keyboard input by select() and wait... >When I hit any key, program goes read() and until EOL is start. And repeat. >(2) waits pipe input by select() and wait. >When I enter some chars and ENTER, then program goes read(). >Both are good behavior. > >With bad DLL, (1) is same to good DLL. But (2) goes read() immediately >although no data is available in PIPE. > >This problem means asyncronous reading using select() is not work if >some input handle is PIPE. For example, OpenSSH executed from NTEmacs is >not work. On this case, ssh.exe goes reading from stdin (PIPE) although >PIPE is empty and blocks processing input from network. > >Described above is phenomena on non cygwin shell (cmd.exe and 4nt.exe). >On bash, it seems working good. But once hit CTRL-C to stop select(), >it hangs. Program cannot terminate select'ing. >It's another problem. > > >I checked tests above on command prompt and 4nt.exe on Windows XP and >Windows 2000 with some cygwin1.dll (ver 1.3.3, snap-20010925, >snap-20010927, snap-20010929, snap-20011001) and get results bellow. > >cygwin1.dll result >----------------------- >1.3.3 good >snap-20010925 BAD >snap-20010927 BAD >snap-20010929 good >snap-20011001 BAD > > > >/* pipe-select.c -- test pipe input select()'ing bug. */ > >#include >#include >#include > >int >main(int argc, char **argv) >{ > int ret; > fd_set ifds; > > if ( isatty(0) ) { > puts("stdin is tty"); > } else { > puts("stdin is NOT tty"); > } > > FD_ZERO(&ifds); > FD_SET(0, &ifds); > printf("selecting..."); fflush(stdout); > ret = select( 1, &ifds, NULL, NULL, NULL); > printf("ret=%d, ifds=0x%x\n", ret, *(long*)&ifds); > if ( FD_ISSET(0,&ifds) ) { > char c;; > printf("reading: ");fflush(stdout); > read(0, &c, 1); > printf("=> '%c'\n", c); > } > return 0; >} >// Local Variables: >// compile-command: "gcc pipe-select.c -o pipe-select" >// End: > > >--- Regards, > Shun-ichi Goto > R&D Group, TAIYO Corp., Tokyo, JAPAN -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/