[PATCH] tty.cc nonblocking pipe

Steve O bub@io.com
Fri Sep 13 10:09:00 GMT 2002

Testing this patch a little more, I've found that WriteFile
may fail in fhandler_tty.cc line ~643.  Failure causes the
process to exit, which is not appropriate.  I'll look at this 
some more over the weekend, but for now, I'd say hold off
on applying this patch. 

On Fri, Sep 13, 2002 at 02:20:04AM -0500, Steve O wrote:
> Hi,
>   I've been tracking down why rxvt hangs when a paste
> is too big, or if you simply cat a file with control
> chars, like rxvt.exe.  What I discovered is that 
> Windows will block writing to an anonymous pipe.  The
> behavior I was seeing was that the child was pretty
> much waiting on writes, which works as long as rxvt
> keeps reading, but if rxvt writes as well (and blocks)
> then deadlock occurs. 
>   So the fix is to make the pipe non-blocking.  In tty.cc
> the to_slave part is set to non-blocking, but the to_master
> isn't.  Odd.  However, setting to_master to non-blocking
> cures the rxvt deadlock.  This fix only works on NT/2K/XP.
> Serious modification would be needed to get 98 to work.
> -steve
> *** tty-orig.cc Thu Sep 12 23:54:32 2002
> --- tty.cc      Thu Sep 12 23:54:08 2002
> ***************
> *** 375,380 ****
> --- 375,382 ----
>     DWORD pipe_mode = PIPE_NOWAIT;
>     if (!SetNamedPipeHandleState (to_slave, &pipe_mode, NULL, NULL))
>       termios_printf ("can't set to_slave to non-blocking mode");
> +   if (!SetNamedPipeHandleState (to_master, &pipe_mode, NULL, NULL))
> +     termios_printf ("can't set to_master to non-blocking mode");
>     ptym->set_io_handle (from_slave);
>     ptym->set_output_handle (to_slave);
>     return TRUE;

More information about the Cygwin-patches mailing list