public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Peterson <joe@skyrush.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Advice sought: pty/tty gets into "gridlock" if it does too much input/output while stopped
Date: Wed, 24 Sep 2008 12:49:00 -0600	[thread overview]
Message-ID: <48DA8B9C.1070200@skyrush.com> (raw)

I've been investigating an issue I ran into recently, and I am not yet sure how
to fix it, so I am soliciting suggestions.

Basically, it is quite easy to "gridlock" (I avoided the term "deadlock", since
this is not a locking issue) a shell/xterm session by stopping the tty (e.g.
hitting ^S) and then causing lots of input and output.  Here is an easy way to
do it:

1) open an xterm
2) type "grep foo"
3) hit ^S
4) paste a large number of lines (more than the 4k size)
   containing the word "foo" (this causes output for every input)

There is now no way to break out of this condition in a normal way.  Signals
(e.g. ^C, ^Z) and ^Q cannot break out of this state, since the input character
cannot make it into the line discipline (I never see it in the buffer in
pty_write() after the condition takes hold).  The only thing that can be done is
to close the xterm window.

The problem is that pty_write() (when trying to process typed characters) finds
that "to->receive_room" is zero, so no data is passed to n_tty_receive_buf(),
and nothing can move.  Since both the reads and writes (both of which pass
through the pty_write() function) are waiting to have some space with which to
work, and the tty is stopped, things are stuck.  Since signal and ^Q chars do
not need buffer space, perhaps these could (perhaps) get a higher priority and
be sent through, but since I do not see them in the pty_write() buffer when
issued *during* the condition, it is not clear where this should be done, or if
it is the right solution.  I've verified this as far back as 2.6.24.

							-Joe



                 reply	other threads:[~2008-09-24 18:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=48DA8B9C.1070200@skyrush.com \
    --to=joe@skyrush.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox