mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Jeff Dike <jdike@addtoit.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: tcsetattr(fd, TCSAFLUSH) on an O_ASYNC pts device always fails
Date: Thu, 29 Nov 2007 00:12:36 +0000	[thread overview]
Message-ID: <20071129001236.4ac069bd@the-village.bc.nu> (raw)
In-Reply-To: <20071127185321.GA8546@c2.user-mode-linux.org>

On Tue, 27 Nov 2007 13:53:21 -0500
Jeff Dike <jdike@addtoit.com> wrote:

> tcsetattr(fd, TCSAFLUSH) will always return -EINTR on a pts device
> when O_ASYNC has been set.  This is demonstrated by the test program
> below - just compile and follow the instructions.  You'll get an
> infinite stream of SIGIOs and -EINTRs.

Cute. This appears to be entirely standards compliant but I agree its not
sane or expected behaviour.

> static void pty_unthrottle(struct tty_struct * tty)
> {
> 	...
> 	tty_wakeup(o_tty);
> 	set_bit(TTY_THROTTLED, &tty->flags);
> }

My first thought would be to only do the tty_wakeup if there is data
pending.

> I'd love to get rid of the set_bit(TTY_THROTTLED, &tty->flags) in
> pty_unthrottle, but it's protected by this comment:
> 
> /* For PTY's, the TTY_THROTTLED
>  * flag is always set, to force the line discipline to always call the
>  * unthrottle routine when there are fewer than TTY_THRESHOLD_UNTHROTTLE 
>  * characters in the queue.  This is necessary since each time this
>  * happens, we need to wake up any sleeping processes that could be
>  * (1) trying to send data to the pty, or (2) waiting in wait_until_sent()
>  * for the pty buffer to be drained.
>  */
> 
> Failing that, there should be a relevant state change in the device
> before it will deliver a SIGIO.  I just have no idea where to put it.

Unfortunately neither am I. If the wakeup can be deferred if there is no
data pending then I think that will do the trick ?

      reply	other threads:[~2007-11-29  0:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 18:53 Jeff Dike
2007-11-29  0:12 ` Alan Cox [this message]

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=20071129001236.4ac069bd@the-village.bc.nu \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=jdike@addtoit.com \
    --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

all inboxes | Powered by JetHome®