Xavier de Gaye wrote:

> On Mon, Dec 6, 2010 at 7:54 PM, Benjamin R. Haskell wrote:
> > If Vim receives a SIGWINCH (_sig_nal that the _win_dow _ch_anged size) while
> > editing stdin, a program piping input to Vim gets killed prematurely.  Is
> > there an easy way to avoid this?
> >
> 
> 
> Actually, it is Vim that terminates prematurely.
> This is a bug in Vim: when vim receives the SIGWINCH signal, the
> vim_read() call that is reading stdin, returns -1 and vim handles that
> as an error in readfile().
> 
> read_stdin  --calls-->  open_buffer  --calls-->  readfile --calls-->  vim_read
> 
> The problem becomes (nearly) fixed when the signals are reset before
> calling open_buffer() in read_stdin(), after having surrounded the call
> to open_buffer() with the following two statements:
> 
>     // reset signals to their default
>     reset_signals();
>     (void)open_buffer(TRUE, NULL, 0); /* create memfile and read file */
>     // restore signals
>     mch_init();
> 
> It is only "nearly" fixed, because when the window is resized, vim
> does not restore the tty to sane attributes (icanon is not set for
> example) after it has successfully done its job.
> 
> I am not sure if the hack above is acceptable. I will look into the tty
> attributes problem.

This looks like a hack.  I think the proper solution is to have
vim_read() check for EINTR and retry.

I'm a bit confused about what happens when read() is interrupted before
reading anything, does it return zero or -1?  Perhaps this depends on
the system.  At least at some point vim_write() assumes it writes
something before being interrupted, that might be wrong as well.

-- 
hundred-and-one symptoms of being an internet addict:
1. You actually wore a blue ribbon to protest the Communications Decency Act.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui