All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Wang YanQing <udknight@gmail.com>,
	jslaby@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH]TTY: Fix tty can't be restarted by TCXONC ioctl request
Date: Tue, 7 May 2013 11:58:00 -0700	[thread overview]
Message-ID: <20130507185800.GA10713@kroah.com> (raw)
In-Reply-To: <20130507184734.GA2459@udknight>

On Wed, May 08, 2013 at 02:47:34AM +0800, Wang YanQing wrote:
> I meet emacs hang in start if I do the operation below:
>   1: echo 3 > /proc/sys/vm/drop_caches
>   2: emacs BigFile
>   3: Press CTRL-S follow 2 immediately
> 
> Then emacs hang on, CTRL-Q can't resume, the terminal
> hang on, you can do nothing with this terminal except
> close it.
> 
> The reason is before emacs takeover control the tty,
> we use CTRL-S to XOFF it. Then when emacs takeover the
> control, it may don't use the flow-control, so emacs hang.
> But after search the emacs's startup codes, I find they use TCXONC
> to workaround this situation:
> 
>   /* This code added to insure that, if flow-control is not to be used,
>      we have an unlocked terminal at the start. */
>   if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TCXONC, 1);
>   ioctl (fileno (tty_out->input), TCXONC, 1);
> 
> But this workaround never work due the kernel's current code.
> This patch fix it.
> 
> Below is the ChangeLog introduce the tty->flow_stopped flag:
> 
> Thu Nov 21 10:05:22 1996  Theodre Ts'o  <tytso@localhost.mit.edu>
> 
>        * tty_ioctl.c (tty_wait_until_sent): Always check the driver
>                wait_until_ready routine, even if there are no characters
>                in the xmit buffer.  (There may be charactes in the device
>                FIFO.)
>                (n_tty_ioctl): Add new flag tty->flow_stopped which
>                indicates whether the tty is stopped due to a request by
>                the TCXONC ioctl (used by tcflow).  If so, don't let an
>                incoming XOFF character restart the tty.  The tty can only
>                be restarted by another TCXONC request.
> 
> So I think this patch make TCXONC can restart tty which stopped by
> STOP_CHAR don't break the original meaning.
> 
> This patch will fix some strange tty relation hang problem,
> I believe I meet it with vim in ssh, and also see below bug report:
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=465823

So this has been a problem since 1996?  Or is it newly introduced due to
some changes in this area in a newer kernel?

thanks,

greg k-h

  reply	other threads:[~2013-05-07 18:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-07 18:47 [PATCH]TTY: Fix tty can't be restarted by TCXONC ioctl request Wang YanQing
2013-05-07 18:58 ` Greg KH [this message]
2013-05-08  1:55   ` Wang YanQing
2013-05-08  2:02     ` Greg KH
2013-05-08 13:16       ` Wang YanQing
2013-05-08 15:18         ` Peter Hurley
2013-05-08 17:12           ` Wang YanQing
2013-05-08 18:32             ` Peter Hurley
2013-05-09  0:42               ` Wang YanQing
2013-05-07 20:50 ` Peter Hurley
2013-05-08  2:00   ` Wang YanQing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130507185800.GA10713@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=udknight@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.